How to compare two dates?
Use the comparison operators <= >= > == and != .
if (LedgerTrans.TransDate > systemDateGet() - 3) LedgerTrans.TransDate = systemDateGet() - 3;
This also works when choosing:
select firstonly LedgerTrans where LedgerTrans.TransDate > systemDateGet() - 3;
It also works in the query input ranges: >13-08 will select the selection dates after August 13 of the current year. See Also: http://kashperuk.blogspot.com/2010/02/utcdatetime-in-dynamics-ax-2009.html
How to convert date to utcDateTime ?
DateTimeUtil::newDateTime(systemDateGet(), 0, DateTimeUtil::getUserPreferredTimeZone()));
See also: http://msdn.microsoft.com/en-us/library/cc584924.aspx
There is no need to convert Date to utcDateTime to compare two dates.
source share