I could use some help deriving a year quarter from a text string that represents a date. I have a string, say ‘20121230’, to represent 12/30/2012. Somehow, someway, I need to convert this value into ‘4Q12.’ I get stuck after converting the 20121230 into a date:
CONVERT(date,datestringfield,111)
I need help deriving the quarter and year from this date and then converting the quarter and year to a string format 4Q12. Any help would be greatly appreciated
If you are using SQL Server, then the particular format of
datestringfieldcan be used as a date unambiguosly. So, you can do: