Join Date and Time to DateTime in C#

后端 未结 8 902
孤城傲影
孤城傲影 2020-12-25 09:46

I am retrieving data from an iSeries where there is a separate date and time fields. I want to join them into a DateTime field in my C# project. I don\'t see a way to add ju

8条回答
  •  鱼传尺愫
    2020-12-25 10:19

    How are they being stored? Assuming that the date portion is being stored as a DateTime of midnight of the day in question and the time is a TimeSpan, you can just add them.

    DateTime date = ...;
    TimeSpan time = ...;
    
    DateTime result = date + time;
    

提交回复
热议问题