Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get current day from current_date function

Status
Not open for further replies.

ChandruN

Programmer
Jun 17, 2003
13
US
How to get current day from current_date function

Thanks
Chandru
 
Bill,

I want something like Monday,Tuesday... Which function I should use.Thanks in Advance.
 
That function is missing in Teradata.
You have to calculate it or use a join to a/the system calendar.

sel
case (current_date - date '0001-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'
else ''
end;


select
case day_of_week
when 2 then 'Monday'
when 3 then 'Tuesday'
when 4 then 'Wednesday'
when 5 then 'Thursday'
when 6 then 'Friday'
when 7 then 'Saturday'
when 1 then 'Sunday'
else ''
end
from sys_calendar.calendar
where calendar_date = current_date;

You usally put that CASE into the calendar definition....

When you already run V2R5, it's
sel trim(current_date (format 'eeee'));

And in the next release there will be User Defined Functions to do all that missing stuff ;-)

Dieter


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top