Skip to content
Advertisement

What is the best method to change Year from YYYY to FYYY format in SQL?

I have year in YYYY format and I want to convert it to FYYY format. So, for instance, 2014 will be FY14, 2009 will be FY09, so on and so forth. I’m creating a View that contains a SUM aggregate function on an amount field. So, the query also contains a Group By clause, just so you are aware.

Advertisement

Answer

A Possible workaround could be

'FY'||to_char(to_date(your_year, 'YYYY'), 'YY')

OR as @Wernfied says like,

to_char(to_date(your_year, 'YYYY'), '"FY"YY')

SQL Fiddle

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement