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

Paul White
95.4k30 gold badges440 silver badges689 bronze badges
asked Oct 22, 2015 at 17:10
0

2 Answers 2

3

Teradata supports Oracle's TO_CHAR syntax since TD14:

TO_CHAR(date, 'q"Q"yy')
answered Oct 22, 2015 at 20:21
-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

Tom V
15.8k7 gold badges66 silver badges87 bronze badges
answered Nov 23, 2016 at 11:15
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.