3 Replies Latest reply on Jan 3, 2017 6:59 AM by user19752

    custom function to return a calculated YYYY/MM

    mrb13676

      I'm trying to create a custom function that will return YYYY/MM for a given number of months ago so I can search on that via a script.

      So if it is January now and I want to search on November's records, I want (for example)my function dateForSearch( 2 ) to return 2016/11.

       

      I have tried with this function but am not having any joy at all..

       

      dateForSearch(monthsBack)

       

      Case ( (Month ( Get ( CurrentDate ) ) - monthsBack)  ≤  0 ; Year ( Get (CurrentDate)) - 1; Year ( Get (CurrentDate)))

      &  "/"  & 

      Case ( (Month ( Get ( CurrentDate ) ) - monthsBack)  ≤  0 ; Month ( Get ( CurrentDate ) ) - monthsBack + 12; Month ( Get (CurrentDate ) ) - monthsBack ))

       

       

      Is this the correct approach? Or am I overcomplicating things?