Home » SQL & PL/SQL » SQL & PL/SQL » Re: Day of week
Re: Day of week [message #35658] Thu, 04 October 2001 06:29
Jon
Messages: 483
Registered: May 2001
Senior Member
Simple answer is:
IF TRIM(To_Char(NEXTDATE,'Day')) = 'Saturday' THEN
SATURDAY := 'Y';
ELSE
SATURDAY := 'N';
END IF;

A more reusable way to do this is to create a stored function:

CREATE OR REPLACE
Function isDateAndDayOfWeekMatching (i_date IN DATE, i_dayOfWeek IN VARCHAR2)
return BOOLEAN
is
begin
return(TRIM(to_char(i_date, 'Day')) = INITCAP(i_dayOfWeek));
end;

Then you can simply use the function inline, as in

IF isDateAndDateOfWeekMatching(NEXTDATE, 'Saturday') THEN... (in place of checking for SATURDAY = 'Y')

and this could be used if you needed to check for Monday, Thursday, etc.

----------------------------------------------------------------------
Previous Topic: hide table
Next Topic: quick question
Goto Forum:
  


Current Time: Sat May 25 10:08:30 CDT 2024