how to calculate count of Quarters in dates?

mdsrmdsr Member Posts: 163
edited 2019-05-28 in NAV Three Tier
need to calculate quarters from Posting date from ILE and user defined date
what is code and where to put it?

Answers

  • ArhontisArhontis Member Posts: 667
    edited 2019-05-30
    Hello,

    Sample code on calculating full quarters between two dates:
    LOCAL CalculateQuarters(piFromDate : Date;piToDate : Date) rQuarterCount : Integer
      rQuarterCount := 0;
      lrDate.SETRANGE("Period Start",piFromDate,piToDate);
      lrDate.SETRANGE("Period Type",lrDate."Period Type"::Quarter);
      IF lrDate.FINDFIRST THEN
        rQuarterCount := lrDate.COUNT;
    

    Usage sample:
    MESSAGE(  
      FORMAT( 
        CalculateQuarters(010119D,311219D)
      )
    );
    

    As to where to use it, that would depend on your need...
Sign In or Register to comment.