Wednesday, February 03, 2010

replace time in datetime value c#

I have 2 datetime values: StartDateTime ('11/01/2010 00:00:00') and NewStartTime('12/02/2010 09:30:00 AM'). I want to replace the time value in StartDateTime with the time value in NewStartTime. In order to achieve so I go:
DateTime NewStartDateTime = new DateTime(StartDateTime.Year, StartDateTime.Month, StartDateTime.Day, NewStartTime.Hour, NewStartTime.Minute, NewStartTime.Second);

No comments: