Date, time
Date
//=== Date
fromDate = str2date(fromDateStr,321);
if empty -> date not valid
Global::dateNull(); //---> Date null : 01/01/1900
dateMax(); //---> Date max : 2154
yesterday = systemdateget() - 1; //---> Today - 1 days
mkdate(day,month,year); //---> To build a new date
date2num(date2) - date2num(date1) = date2 - date1 //----> difference in days between 2 date
dateDay = systemdateget(); //return the system date and don't use UTC and timezone.
dayOfMth(date); // day of the date
MthOfYr(date); // month of year
year(date)); // year of the date
dateStartMth(date); // First day of the month
dateEndMth(date); // Last day of the month
prevYr(invDateDate); //year before , nextYr : next year.
dateMthFwd(dateMonth_i,i) // add i months to the date
date2Str
date dateDay = systemDateGet();
dateStr=strrem(date2str(systemdateget(), 321, 2, -1, 2, -1, 4),'/'); //strrem : remove of the '/';
DateSeparator::Hyphen = "-"
static void Job2(Args _args)
{
date currentDate = today();
str s;
int iEnum;
s = date2Str(currentDate,321,DateDay::Digits2,
DateSeparator::Hyphen,DateMonth::Digits2,
DateSeparator::Hyphen,DateYear::Digits4);
info("Today is: " + s);
}
/** Example Infolog output
Message (12:36:21 pm)
Today is: 2009-01-13
**/
DateTime
//=== UtcDateTime
UtcDateTime dateTimeInvoice;
dateDay = systemDateget();
dateTimeInvoice = DateTimeUtil::getSystemDateTime(); //DateTime AX with TZ if it is 11:00 in Israel -> 09:00)
dateTimeInvoice = DateTimeUtil::utcNow(); //(DateTime System with TZ if it is 11:00 in Israel -> 09:00)
The explanation is that in tools > Session Date, we see that the Time zone of Israel is GMT + 2. In the data Base of the date
are in date Time of GMT.
Date system : '08/01/2013' 16:00:00
dateTimeFrom = DateTimeUtil::newDateTime(DateFrom, 0); //-> '08/01/2013 00:00:00'
dateTime = DateTimeUtil::newDateTime(_date,0,DateTimeUtil::getUserPreferredTimeZone()); //-> '08/01/2013 14:00:00' (date system -2)
dateTime = DateTimeUtil::removeTimeZoneOffset(dateTime
DateTimeUtil::applyTimeZoneOffset(DateTimeUtil::getSystemDateTime(),
DateTimeUtil::getUserPreferredTimeZone());
DateTimeUtil::maxValue()
//Date time null :
DateApprovedUtc = utcDateTimeNull(); ==> date time null;
Time
//=== Time
now = timenow(); //---> System Time
timestr = strrem(time2str(now,1,1),':');
dateTimeInvoice = DateTimeUtil::toStr; is better because it not depend of the parameter of the system
int timeOfDay1,timeOfDay2,timeOfDay3;
timeOfDay1 = str2time('01:00:01');
timeOfDay2 = str2time('02:00:01');
timeOfDay3 = timeOfDay2 - timeOfDay1; //---> difference in seconds.
timeOfDay = str2time('01:00:01'); //--->there is not milli-seconds.
time2str(timeNow(),TimeSeparator::Colon,TimeFormat::Hour24)
info(strFmt("@SPL4285",time2str(timeNow(),TimeSeparator::Colon,TimeFormat::Hour24)));
Notes
notes
-----
http://kashperuk.blogspot.co.il/2010/02/utcdatetime-in-dynamics-ax-2009.html
AX 2012 : timeconsumed : http://dynamicsaxgyan.wordpress.com/2012/01/12/timeconsumeda-very-useful-function-in-global-class-in-ax-2012-x/
//to see
public void new(
DateEffectivenessMap _dateEffectivenessMap,
boolean _deleteRecord = false)
{
;
current = _dateEffectivenessMap;
deleteRecord = _deleteRecord;
dateMin = DateEffectivenessCheck::removeTime(DateTimeUtil::minValue());
dateMax = DateEffectivenessCheck::removeTime(DateTimeUtil::maxValue());
this.setBuffer(current);
}