Join Date and Time to DateTime in C#

c#, datetime

Solution

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;

Problem

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 just a time to a DateTime field. How would you suggest accomplishing this?

Original source