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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Return Day of Week (spelled out) 1

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I'm new to Oracle. In Oracle 8i, is it possible to write an SQL statment that returns the day of the week (i.e. "Wednesday"), when the day number is supplied (hard-coded i.e. "3") as a WHERE parameter?

I was basing the query on SYSBASE, but of course I can only return the current day name or number.

Any help is appreciated,
DinaZ.
 
Yes, just have a simple table with values 1 - 7 in one column and the days in another column and select as necessary.

This is an easy fix to that; what I suspect you really would like to do is get a day of the week for a given date, and this is how you do that:

declare
v_dow VARCHAR2(12);

-- will give you today's date
v_testDate Date := trunc(SYSDATE);
BEGIN
v_dow := To_Char(v_testDate,'DAY');
dbms_output.putline(v_dow);
END;

 
The following query should do the trick:

select to_char(next_day(sysdate,'Sunday')+3,'Day') from dual

You can embed this sql in a function and pass the offset as input.
 

stevecal,
I'm a bit timid of PL/SQL, but I understand your fix.


karluck,
This works great too. I think this is the route I'll go


Thanks to both of you!!
DinaZ
:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top