How to identify date falls in which quarter |Oracle SQL |

 I am bit stuck at this part not getting how to write query for it

Have basic knowledge on SQL , no idea about CASE statement

Need to find my date falls in which Quarter and print output in this format BYYYY : Q12017

B : means => Quarter

YYYY : means => Year

The date format is : 'dd-MON-yy' : '1-JAN-20'

As the above date falls in Quarter 1 so my output will be return : Q12017

Can some one explain how it can be achieved ?

I tried to do it with below approach

Do Substr for date -> cut date , month , year and then how to check where it falls in which quarter ?


select to_char(datecol, 'YYYY"Q"Q')

No comments:

Post a Comment