Date Calculation

MadhanMadhan Member Posts: 96
edited 2006-12-13 in Navision Attain
Hi All,

Here I am facing some problem in calculating dates.
Here is my scenario. I have three fields like

Starting Date (mm/dd/yy)
Ending Date (mm/dd/yy)
Invoice Period (with a value like Month, Two Month, quarter, Half year, year).

So, If I give the value of starting date as 12/13/06 and ending date as 04/30/07 and Invoice Period as Month.

Then, I should get the answer as 01/01/07, 02/01/07, 03/01/07, 04/01/07 (mm/dd/yy)

Plz help me out.

Comments

  • David_CoxDavid_Cox Member Posts: 509
    You cannot use CALCDATE in this scenario, unless the Start Date and End Date are set as the first and last days of the Month.

    The End Date should not be entered but calculated based on the Invoice Period = Month, Two Month, quarter, Half year, year.

    Is this the case?
    Can you explain better how this will be used?
    Analyst Developer with over 17 years Navision, Contract Status - Busy
    Mobile: +44(0)7854 842801
    Email: david.cox@adeptris.com
    Twitter: https://twitter.com/Adeptris
    Website: http://www.adeptris.com
  • WaldoWaldo Member Posts: 3,412
    First you should calculate the first date:
    in your case, you should use something like: datDate := CALCDATE('<-CM+1M>',datDate);

    For the next, you can use for:
    Month: datDate := CALCDATE('<1M>',datDate);
    Two Month: datDate := CALCDATE('<2M>',datDate);
    quarter: datDate := CALCDATE('<4M>',datDate);
    Half year: datDate := CALCDATE('<6M>',datDate);
    year: datDate := CALCDATE('<1Y>',datDate);

    It is rather easy to put this into a loop to see if your date has passed the ending date.

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
Sign In or Register to comment.