how to filter posting date by year?

julkifli33julkifli33 Member Posts: 1,087
hi all
i create variable year (text)
how to filter posting date by that variable ?
FORMAT("Posting Date",0,'<Day,2>/<Month,2>/<Year4>'),Year);
--> failed
can anyone tell me what's wrong with my code?
thanks

Answers

  • kinekine Member Posts: 12,562
    What about this:
      SETRANGE("Posting Date",DMY2DATE(1,1,Year),DMY2DATE(31,12,Year));
    

    8)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • julkifli33julkifli33 Member Posts: 1,087
    hi
    thanks a lot kine
    but how about if i want to use end of month
    like for example if i want to use february

    SETRANGE("Posting Date",DMY2DATE(1,Month,Year),DMY2DATE(31,Month,Year));
    how to indicate that not 31
    but end of month
  • julkifli33julkifli33 Member Posts: 1,087
    no need
    solved already
    thanks a lot :)
  • kinekine Member Posts: 12,562
    o not forget about possibility to use CALCDATE('<-CM>',MyDate) and CALCDATE('<CM>',MyDate) to find beginning and end of month, same for <-CY> and <CY> for beginning and end of year.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • julkifli33julkifli33 Member Posts: 1,087
    kine wrote:
    o not forget about possibility to use CALCDATE('<-CM>',MyDate) and CALCDATE('<CM>',MyDate) to find beginning and end of month, same for <-CY> and <CY> for beginning and end of year.

    noted kine , thanks
    but i'm using this code is enough
    SETRANGE("Posting Date",DMY2DATE(1,Month,Year),DMY2DATE(1,Month+1,Year)-1);
    
  • kinekine Member Posts: 12,562
    It is not enough, it will not work for last month in the year... :D
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.