Quantcast
Channel: Teradata Forums - Database
Viewing all articles
Browse latest Browse all 14773

Fetching the data for thelast quarter dates - response (6) by dnoeth

$
0
0

What's your TD release?
In 14 there's Oracle's TRUNC:

WHERE datecol BETWEEN TRUNC(ADD_MONTHS(CURRENT_DATE,-3), 'Q'), TRUNC(CURRENT_DATE, 'Q') - 1

Before it's more complicated:

WHERE datecol BETWEEN ADD_MONTHS(CURRENT_DATE - (EXTRACT(DAY FROM CURRENT_DATE) -1), -(EXTRACT(MONTH FROM CURRENT_DATE) + 2) MOD 3 - 3)
                  AND ADD_MONTHS(CURRENT_DATE - (EXTRACT(DAY FROM CURRENT_DATE) -1), -(EXTRACT(MONTH FROM CURRENT_DATE) + 2) MOD 3) - 1

 


Viewing all articles
Browse latest Browse all 14773

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>