Re: Another annoying SQL date question...
Date: 1996/06/21
Message-ID: <31CB0BDA.28EE_at_asymetrix.com>#1/1
Frampton Steve R wrote:
>
> Hello:
>
> Using straight SQL, when given a start date and an end date,
> how can one determine whether a Friday or a Monday exists during
> the date span.
>
> Eg. "960601 - 960601" - no, does not contain a Friday or Monday
> Eg. "960601 - 960602" - no, does not contain a Friday or Monday
> Eg. "960601 - 960610" - yes, contains a Friday and/or Monday
>
> (note first example starts and stop on same day)
>
> Any information would be greatly appreciated. I will continue to try and
> figure this out, and if I get it first I'll post a summary anyway. :-)
>
> --------------< LINUX: The choice of a GNU generation.
>---------------> Work: <frampton_at_mail.flarc.edu.on.ca> School: <3srf_at_qlink.queensu.ca>
> Steve Frampton http://qlink.queensu.ca/~3srf
Try using the to_char function with a format of 'D'. This will return what day of the week it is where 1=Sunday, 2=Monday, etc. You should then be able to determine if the day your looking for exists within your date range.
For example:
SELECT 'Yes'
FROM DUAL
WHERE '6' BETWEEN TO_CHAR(TO_DATE('061096','MMDDYY'),'D') AND
TO_CHAR(TO_DATE('060196','MMDDYY'),'D');
Hope it helps.
Tim perrault
timp_at_asymetrix.com
Asymetrix Corporation
Received on Fri Jun 21 1996 - 00:00:00 CEST