adventurous1
Programmer
Another brain teaser from a newbie...
I need to compare two dates, a TRIPSTARTDATE and TRIPENDDATE, to return a value to populate a Y/N flag in a column called INCL_WEEKEND.
I am trying to accomplish this in a SQL statement but figure that it is better suited towards a PL/SQL function.
Can anyone assist with the PL/SQL function?
Big Thanks...
Adventurous
Examples:
(1) TRIPSTARTDATE='02-MAR-04' (a Tuesday)
TRIPENDDATE='08-MAR-04' (the following Monday)
>>In this case, the INCL_WEEKEND flag should be set to "Y", as a weekend day (Friday, Saturday, Sunday) falls in between these dates.
(2) TRIPSTARTDATE='02-MAR-04' (a Tuesday)
TRIPENDDATE='04-MAR-04' (a Thursday)
>>In this case, the INCL_WEEKEND flag should be set to "N", as the trip period does not contain a weekend day (Friday, Saturday, Sunday) between these dates.
(3) TRIPSTARTDATE='05-MAR-04' (a Friday)
TRIPENDDATE='07-MAR-04' (a Sunday)
>>In this case, the INCL_WEEKEND flag should be set to "Y", as the trip period does contain a weekend day (Friday, Saturday, Sunday) between these dates.
(4) TRIPSTARTDATE='06-MAR-04' (a Saturday)
TRIPENDDATE='09-MAR-04' (a Tuesday)
>>In this case, the INCL_WEEKEND flag should be set to "Y", as the trip period does contain a weekend day (Friday, Saturday, Sunday) between these dates.
I need to compare two dates, a TRIPSTARTDATE and TRIPENDDATE, to return a value to populate a Y/N flag in a column called INCL_WEEKEND.
I am trying to accomplish this in a SQL statement but figure that it is better suited towards a PL/SQL function.
Can anyone assist with the PL/SQL function?
Big Thanks...
Adventurous
Examples:
(1) TRIPSTARTDATE='02-MAR-04' (a Tuesday)
TRIPENDDATE='08-MAR-04' (the following Monday)
>>In this case, the INCL_WEEKEND flag should be set to "Y", as a weekend day (Friday, Saturday, Sunday) falls in between these dates.
(2) TRIPSTARTDATE='02-MAR-04' (a Tuesday)
TRIPENDDATE='04-MAR-04' (a Thursday)
>>In this case, the INCL_WEEKEND flag should be set to "N", as the trip period does not contain a weekend day (Friday, Saturday, Sunday) between these dates.
(3) TRIPSTARTDATE='05-MAR-04' (a Friday)
TRIPENDDATE='07-MAR-04' (a Sunday)
>>In this case, the INCL_WEEKEND flag should be set to "Y", as the trip period does contain a weekend day (Friday, Saturday, Sunday) between these dates.
(4) TRIPSTARTDATE='06-MAR-04' (a Saturday)
TRIPENDDATE='09-MAR-04' (a Tuesday)
>>In this case, the INCL_WEEKEND flag should be set to "Y", as the trip period does contain a weekend day (Friday, Saturday, Sunday) between these dates.