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

Get last full 20 weeks with function ADD_MONTHS(date - EXTRACT(day FROM date) +0, 0) - forum topic by Nexsn

$
0
0

Hi community,
first of all, sorry for my bad english, I'm doing by best!
 
I've a question. I need to get database-entries for the last full 20 weeks, but the query should be dynamic.

Example for data-entries for the last full 12 months:
WHERE
CAST(i.Timestamp_TS AS DATE) > ADD_MONTHS(date - EXTRACT(day FROM date) +0, -13) +0
AND
CAST(i.Timestamp_TS AS DATE) < CAST(CURRENT_DATE as DATE)
I need a funktion like this but like I said, for the last full 20 weeks. No Matter when I start the query.
But I guess i cannot do this with that function!?
Is it possible to make this without using table "Sys_Calendar.Calendar"?
 
Thanks for reading and answering!
Greets!

Forums: 

Viewing all articles
Browse latest Browse all 14773

Trending Articles



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