Date Functions

Date functions are quite often used and needed. Here are some samples:

  1. Calculate the 1st of current month:
    EndDate := CALCDATE('-CM');
    
  2. Calculate last day of current month:
    EndDate := CALCDATE('CM');
    
  3. 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');
    
  4. 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.

One thought on “Date Functions

Leave a comment