c# - How to merge two nullable DateTime objects one contaning time other date I need into one object? -
i've got 2 datetime
objects. fetchtime
contains time hh:mm:ss
insterested in, fetchdate
contains date: year, month, day.
example:
debug.writeline("time " + fetchtime); debug.writeline("date " + fetchdate);
displays example:
time 2014-09-10 23:04:00 date 2014-09-15 00:00:00
and datetime
object looks that:
2014-09-15 23:04:00
i merge 2 1 or modify 1 of them. thought easy can't see methods datetime
object. achievable or first must convert datetime
type convert back? finally, have have datetime
object because going added sql database .
edit:
i refer nullable datetime
: datetime? fetchdate, datetime? fetchtime
.
just use datetime
constructor
var date = new datetime(fetchdate.year, fetchdate.month, fetchdate.day, fetchtime.hour, fetchtime.minute, fetchtime.second);
update: seems using nullable datetime
. should underlying datetime
value using value
property.
var fetchdate = fetchdate.value; var fetchtime = fetchtime.value; var date = new datetime(fetchdate.year, fetchdate.month, fetchdate.day, fetchtime.hour, fetchtime.minute, fetchtime.second);
Comments
Post a Comment