0

I need Teradata SQL syntax to extract quarter from a date:

Date: (YYYY-MM-DD)
2015-09-12
2015-05-22
2014-12-15

Given below is the expected output:

3Q15
2Q15
4Q14

Query which I have tried (wrapped for readability):

SELECT DATE, ((CAST(EXTRACT(MONTH FROM DATE) AS BYTEINT)-1)/3)+1 
    || 'Q' || substring(DATE,3,2) quarter

Error:

Missing parameters

0

2 Answers 2

3

Teradata supports Oracle's TO_CHAR syntax since TD14:

TO_CHAR(date, 'q"Q"yy')
-2
sel curr_payment_quarter, 
    ((CAST(EXTRACT(MONTH FROM curr_payment_DATE) AS BYTEINT)-1)/3)+1 
    || 'Q' || substring(curr_payment_quarter,3,2)  as quarter,
    curr_payment_DATE
from PAYMENT_DETAILS

To be clear, Teradata supports sel as a shortcut for select

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.