5 Replies Latest reply on Apr 1, 2016 9:25 AM by Joe Oppelt

    Date range

    Balapradeep CK

      Basically I am working in a project where the Financial year starts from July, I have date field so I need a column that shows which financial year that date field fall in to.

       

      for example the date 20-01-2016 will be FY16, 27-07-2013 will be FY14.....

       

      Can we use case statement or IF statement here?

       

      I use below SQL statement using case

       

       

      CASE WHEN date_field BETWEEN '2013-07-01' AND '2014-06-01' THEN 'FY2014'


      WHEN date_field BETWEEN '2014-07-01' AND '2015-06-01' THEN 'FY2015'


      WHEN date_field BETWEEN '2015-07-01' AND '2016-06-01' THEN 'FY2016'


      WHEN date_field BETWEEN '2016-07-01' AND '2017-06-01' THEN 'FY2017' END AS FINANCIAL_YEAR

       

       

      Appreciate any help

       

      Regards,

      Bala