views:

540

answers:

2

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

+3  A: 

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));
Jay Hofacker
Thanks for the help!
Brad
A: 

Logic for utcdatetime :

utcdateTime testDonedateTime1; utcdateTime testDonedateTime; transdate tmpDate ; timeofday tmpTime;

testDonedateTime1 = inventJournalTable. PostedDateTime; tmpDate = DateTimeUtil::date(testDonedateTime1); tmpTime = DateTimeUtil::time(DateTimeUtil::applyTimeZoneOffset(testDonedateTime1, DateTimeUtil::getUserPreferredTimeZone()));

                testDonedateTime  = DateTimeUtil::newDateTime(tmpDate,TmpTime);

Important : utcDateTime control properties TimeZonePreference set No conversion

Arpan Sen