How to calculate date if different year

tneurbtneurb Member Posts: 9
How to calculate date if different year

Comments

  • kinekine Member Posts: 12,562
    Sorry, can you be more specific? Do you need add a year to some date or what?

    For calculating dates is function CALCDATE...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • tammakittammakit Member Posts: 5
    If you want to calculate days between dates which have different years, you can use a variable type DURATION to keep the day count.

    :P

    // From C/SIDE Reference Guide
    DURATION
    Use this data type to represent the difference between two datetimes, in milliseconds. This value can be negative. It is a 64 bit integer.

    DATETIME-DATETIME=DURATION

    DATETIME-DURATION=DATETIME

    DATETIME+DURATION=DATETIME
  • KowaKowa Member Posts: 925
    Example to calculate a period for the last year set in a date filter field
    FirstDay := GETRANGEMIN("Date filter");
    LastDay := GETRANGEMAX("Date filter");
    FirstDayLastYear := CALCDATE('<-1Y>',FirstDay);
    LastDayLastYear := CALCDATE('<-1Y>',LastDay);
    SETRANGE(LastYearfilter,FirstDayLastYear,LastDayLastYear);
    

    of, if possible, take a look in Codeunit 6 and Codeunit 8 (into Function SetGLAccColumnFilters) to see other working code examples for the calculation of date filters.
    Kai Kowalewski
Sign In or Register to comment.