Date filter Code

peloffispeloffis Member Posts: 18
Looking for date filter for first day of year. Looking to feed a filter FirstDayofYear to CurrentDate. Closed I could find was Mon1 for Monday of Week 1, not quite it.

Thanks!

Comments

  • swjswj Member Posts: 68
    Using CALCDATE('-CY',TODAY))

    It will return 01/01/10 \:D/
  • kinekine Member Posts: 12,562
    swj wrote:
    Using CALCDATE('-CY',TODAY))

    It will return 01/01/10 \:D/

    WRONG!


    CORRECT: CALCDATE('<-CY>',TODAY))

    When giving advice, try to follow basic rules for the code... ;-)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • matttraxmatttrax Member Posts: 2,309
    kine wrote:
    WRONG!


    CORRECT: CALCDATE('<-CY>',TODAY))

    Both will work just fine. All of the examples may use < and >, but they are not required for it to work. Personally I think they just clutter the formula. Do they serve some purpose that I am not aware of?
  • vaprogvaprog Member Posts: 1,139
    If I run matttrax's code on my German client, I get a runtime error, because the date formula is not recognisable.
    If I run kine's code, everything is allright.

    A DateFormula entered as string is interpreted according to the current language unless it is surrounded by angle brackets, in which case it is interpreted in English.
    Real DateFormula values are language independent, but there are no literals for the DateFormula type.
  • peloffispeloffis Member Posts: 18
    I forgot to mention that we are on a fiscal year <> then the calendar year. I will try the suggustions. And keep checking for updates. Much thanks.
  • kinekine Member Posts: 12,562
    matttrax wrote:
    Both will work just fine. All of the examples may use < and >, but they are not required for it to work. Personally I think they just clutter the formula. Do they serve some purpose that I am not aware of?
    As vaprog wrote - main reason is the MULTILANGUAGE. Czech do not have CY thus you will get runtime error in other languages, which are using different characters for the dateformula. In Czech it should be 'BR'. Thus the <> is needed each time you are using the dateformula consant in the code. It is same like using textconstant versus direct text in e.g. Error.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.