Axapta: Convert utcDateTime to date

Brad picture Brad · Dec 29, 2009 · Viewed 36.4k times · Source

What is the best way to convert a utcDateTime value to a date type so I can use the global datetime functions on it?

int timeDiff;
date _now = systemdateget();
;

select firstOnly myUTCDateTime from _myTable
timeDiff = Global::yearDiff(_now, _myTable.myUTCDateTime);
info(strfmt('%1', timeDiff);

Thanks

Answer

Jay Hofacker picture Jay Hofacker · Dec 29, 2009

The DateTimeUtil Class has methods for dealing with utcdatetime variables. In your case you would use DateTimeUtil::date.

timeDiff = Global::yearDiff(_now, DateTimeUtil::date(_myTable.myUTCDateTime));