Archives of the TeradataForum
Message Posted: Thu, 22 May 2003 @ 17:31:03 GMT
Subj: | | Re: Extract day of week from date |
|
From: | | Hough, David A |
I generally use the system calendar unless adding the table would do bad things to my joins. In that case I use something like the code
Nathan Updyke proposed, though simplified:
select case (date - date '1900-01-01') mod 7
when 0 then 'Monday'
when 1 then 'Tuesday'
when 2 then 'Wednesday'
when 3 then 'Thursday'
when 4 then 'Friday'
when 5 then 'Saturday'
when 6 then 'Sunday'
end as DAY_OF_WEEK;
If you don't like CASE, you can use:
select
substring('Monday Tuesday Wednesday Thursday Friday Saturday Sunday '
from (1+10*((date - date '1900-01-01') mod 7)) for 10)
as DAY_OF_WEEK;
/dave
|