preloader-matrix

Alfasith

Difference between two dates in days in Dynamic AX

To get the difference between two dates in dynamics ax just convert the dates into numbers and subtract one from the other. The result would be the amount of days between these dates.


today() – mkdate(31,01,2011) ;
or
days = date2num(Date123) – date2num(Date234);
or
TblName.FieldName= date2num(today()) – date2num(AnotherTblName.DatefeildName);


days = date2num(Date123) – date2num(Date234);

To get the difference between two DateTime Values just use the DateTimeUtil Class. The result is the difference in seconds. So just divide these through #secondsPerDay and you’ll get the days

#timeConstants

days = DateTimeutil::getDifference(DateTime123, DateTime234) / #secondsPerDay;

——————————————————————-
date2num(systemdateget()) – date2num(urtable.date);
———————————————————————————————————
static void DateDiff(Args _args)
{
    TransDate   d1,d2;
    int daysdiff;
    ;
    d1  = 31122010;
    d2  = today();
    daysDiff = d2 – d1;
    info(strfmt(“%1”,daysDiff));
}
—————————————————————————————————–
Or just override the field in datasource level as modified()

then
tablename.fieldName3 = tablename.fieldName2 – tablename.fieldName1;
filedName1 – Out put field,
filedName2 – To date field,
filedName2 – from date field,

Share on email
Share on facebook
Share on twitter
Share on linkedin
Share on pinterest

Leave a Reply

Your email address will not be published.