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.
----------------------------------------------------------------------
|
|
|