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...

Today I simply have a quick tip. I needed 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);


No comments:

Post a Comment

Note: Only a member of this blog may post a comment.