Monday, October 3, 2011

A Now() or GetDate() Method for AX

It should be noted, that after I made this post, it was revealed to me that the DateTimeUtil::utcNow() method accomplishes this goal...

If we need to be able to obtain the current date & time; something similar to the DateTime.Now() function in .NET or the getdate() function in SQL Server; However as far as I can tell, AX provides no quick function for this, so I wrote my own:
public utcdatetime Now()
str tDate;
str tTime;
utcdatetime utc3;


tDate = date2str(systemDateGet(), 321, DateDay::Digits2, DateSeparator::Hyphen, DateMonth::Digits2, DateSeparator::Hyphen, DateYear::Digits4);
tTime = time2Str(TimeNow(), TimeSeparator::Colon, TimeFormat::AMPM);
return str2datetime(tDate + " " + tTime, 321);

Enjoy DAX !!!

No comments:

Post a Comment

Thanks for your time reviewing this blog.