Date functions are quite often used and needed. Here are some samples:
- Calculate the 1st of current month:
EndDate := CALCDATE('-CM');
- Calculate last day of current month:
EndDate := CALCDATE('CM');
- Calculate the end date of a defined period (e.g.3 months) starting with the 1st of the current month; get the last day of the end month:
EndDate := CALCDATE('-CM+3M-1D'); EndDate := CALCDATE('CM+2M');
- Get start and end date of a period with given day values and variable month value:
startDay, endDay, month, prevMonth, currYear | integer values month := 10 // sample value if month > 1 then prevMonth := month - 1 else prevMonth := 12; currYear := DATE2DMY(TODAY,3); // get current year startDate := DMY2DATE(startDay, month - 1, currYear); endDate := DMY2DATE(endDay, month, currYear);
Be aware that the calc formulars are language specific. For german language e.g. use LM instead of CM, 1T instead of 1D.
Or you just use CALCDATE(”, TODAY) instead – that removes the language specific problem when programming.
LikeLike