Quantcast
Channel: Teradata Forums - All forums
Viewing all articles
Browse latest Browse all 27759

Get current week number from the date in current year. - response (1) by dnoeth

$
0
0
Week number based on which definition? This is a SQL function for TD13.10 to calculate it based on the International Standard, i.e. week starts on monday and the first week always includes jan 4. REPLACE FUNCTION iso_week(cdate DATE) RETURNS INT SPECIFIC iso_week_date RETURNS NULL ON NULL INPUT CONTAINS SQL DETERMINISTIC COLLATION INVOKER INLINE TYPE 1 RETURN   (((cDate - (((cdate - DATE '0001-01-01') MOD 7) + 1) + 4)   - ((EXTRACT(YEAR FROM (cDate - (((cdate - DATE '0001-01-01') MOD 7) + 1) + 4)) - 1900) * 10000 + 0101 (DATE))) / 7) + 1  (FORMAT '99') Otherwise you might join to sys_calendar.calendar or check how it's calculating it. Dieter

Viewing all articles
Browse latest Browse all 27759

Trending Articles



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