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) - response (2) by Nexsn

$
0
0

First of all, thanks for your help!
I've to say that I'm new the teradata and the whole database thing!
I do not completly understand this function.
Sure I know what mod is. But why subtract 0001-01-07 from my column and then mod 7?
For example today. That makes no sense to me :(
2013-06-05 - Date '0001-01-07' --> !?
 
and shame to me, how can i substract 20*7 days in this case?
 
my query:
select
i.Abschluss_Erledigt_TS
from
tabelle i
where
CAST(i.Abschluss_Erledigt_TS AS DATE) <= current_date
and
CAST(i.Abschluss_Erledigt_TS AS DATE) >= (CAST(i.Abschluss_Erledigt_TS AS DATE) - ((CAST(i.Abschluss_Erledigt_TS AS DATE) - DATE '0001-01-07') MOD 7)-20*7)
order by 1 desc
 
Thanks again for your help!
 
 
 


Viewing all articles
Browse latest Browse all 14773

Trending Articles



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