to get date in qaurter format like 2Q17

Database
New Member

to get date in qaurter format like 2Q17

Hi I wanr list all quarters in format 1Q17,2Q17 how to convert plz suggest.

2 REPLIES
Teradata Employee

Re: to get date in qaurter format like 2Q17

Depends mainly on how you identify Quarter / year values (e.g. according to business / fiscal calendar)?

Then you can convert those values to your desired display format. For example:

CAST(td_quarter_of_year(theDate) AS VARCHAR(1))||'Q'||CAST(CAST(theDate AS FORMAT 'YY') AS VARCHAR(2))

 

You may want create a SQL UDF to do this.

 

Or build a calendar table with one row per date that includes various display formats, and join to that.

Junior Contributor

Re: to get date in qaurter format like 2Q17

Using TO_CHAR:

To_Char(datecol, 'Q"Q"yy')