Reputation: 17383
Scenario:
Third party web service returns datetime
in two separate fields i.e. date and time. I need a way to concatenate into single field.
e.g.
startDate='24-06-2012'
startTime='1-01-1970 1:00:00 AM'
Expected result:
fullStartDateTime='24-06-2012 1:00:00 AM'
I tried to get the TimeSpan part from startTime and got no where. Could someone let me know if there's a smart way to achieve above.
Upvotes: 28
Views: 55471
Reputation: 102793
TimeOfDay is the property of DateTime that you're looking for:
TimeSpan timeOfDay = startTime.TimeOfDay;
DateTime fullStartDateTime = startDate.Add(timeOfDay);
Upvotes: 66