CREATE DATE WITH WEEKDAY,WEEK AND YEAR TERADATA

Teradata Applications
New Member

CREATE DATE WITH WEEKDAY,WEEK AND YEAR TERADATA

I have a weekday(0,1,2,3,4,5,6) for Sat/Sun/Mon/Tue/Thu/Fri and Weeknum like
1,2...53, I have a year (2018). Now I want to create a date with these three fields, how can I do it?

1 REPLY
Highlighted
Teradata Employee

Re: CREATE DATE WITH WEEKDAY,WEEK AND YEAR TERADATA

Typically it's best to build a calendar table that relates a date to the combination of values.

At a minimum, you probably want a table (or maybe a CASE statement, which could be put in a SQL UDF) that will give you the first date for a given "year" value.

Then it's simple math - FirstDateOfYear(2018) + (Weeknum - 1) * 7 + weekday.