lundi 24 janvier 2011

How to calculate the difference between two dates and set the value automatically in a field of a grid after choosing two values from X++

You have a grid where you can select the StartDate and the EndDate of  the vacation, and you have a field for the calculation of the differnce in days between these two fields:








You can override the method leave of the grid  and use this code for example to calculate the diffrence:
public boolean leave()
{
    Boolean                ret;
    StartDate              inputDate;
    EndDate                refDate;
    ret = super();

    inputDate = str2Date(strFmt("%1",DropHoliday_1.StartDate), 123);
    refDate = str2Date(strFmt("%1",DropHoliday_1.EndDate), 123);
    DropHoliday_1.DaysHoliday=intvNo(refDate, inputDate, intvScale::YearMonthDay);
    return ret;
}

Happy Daxing!

Aucun commentaire:

Enregistrer un commentaire