This job will explain how to set different operations on date conrol in AX using Global class:
static void GlobalClass(Args _args)
{
Date newDate;
;
//Normal Dates
info("Normal Dates:");
//Get's today's date.
info(strfmt('%1', today()));
//Get's minimum/empty date (i.e. 1/1/1900).
//Tough for this one you are not able to see the output as 1/1/1900, but when you set this to
//database field you will see 1/1/1900 set in the date control.
info(strfmt('%1', Global::dateNull()));
//Get's maximum date (i.e. 12/31/2154).
info(strfmt('%1', Global::dateMax()));
//How to add 2 months in date
newDate = Global::dateMthFwd(today(), 2);
info(strfmt('%1', newDate));
}
Output:
Showing posts with label minimum date. Show all posts
Showing posts with label minimum date. Show all posts
Wednesday, 23 May 2012
How to get minimum/empty,maximum date and DateTime in user preferred time zone for utcDateTime control
This job will explain the simple usage of DateTimeUtill class in AX.
static void UtcDateTimeClass(Args _args)
{
Date todaysDate;
;
//UTC Date Time
info("UTC Dates:");
//Get's today's utc date time.
info(strfmt('%1', DateTimeUtil::utcNow()));
//Get's minimum utc date time (i.e. 1/1/1900).
//Tough for this one you are not able to see the output as 1/1/1900, but when you set this to
//database field you will see 1/1/1900 set in the date control.
info(strfmt('%1', DateTimeUtil::minValue()));
//Get's minimum utc date time (i.e. 1/1/1900).
info(strfmt('%1', utcDateTimeNull()));
//Get's maximum utc date time (i.e. 12/31/2154).
info(strfmt('%1', DateTimeUtil::maxValue()));
//Convert UtcDateTime to normal date
todaysDate = DateTimeUtil::date(DateTimeUtil::utcNow());
info(strfmt('%1',todaysDate));
//How to get the time in user time zone
info(strfmt('%1', DateTimeUtil::applyTimeZoneOffset(DateTimeUtil::utcNow(),
DateTimeUtil::getUserPreferredTimeZone())));
}
Output:
static void UtcDateTimeClass(Args _args)
{
Date todaysDate;
;
//UTC Date Time
info("UTC Dates:");
//Get's today's utc date time.
info(strfmt('%1', DateTimeUtil::utcNow()));
//Get's minimum utc date time (i.e. 1/1/1900).
//Tough for this one you are not able to see the output as 1/1/1900, but when you set this to
//database field you will see 1/1/1900 set in the date control.
info(strfmt('%1', DateTimeUtil::minValue()));
//Get's minimum utc date time (i.e. 1/1/1900).
info(strfmt('%1', utcDateTimeNull()));
//Get's maximum utc date time (i.e. 12/31/2154).
info(strfmt('%1', DateTimeUtil::maxValue()));
//Convert UtcDateTime to normal date
todaysDate = DateTimeUtil::date(DateTimeUtil::utcNow());
info(strfmt('%1',todaysDate));
//How to get the time in user time zone
info(strfmt('%1', DateTimeUtil::applyTimeZoneOffset(DateTimeUtil::utcNow(),
DateTimeUtil::getUserPreferredTimeZone())));
}
Output:
Subscribe to:
Posts (Atom)