Good day, I am working on some code where -
1) if a request was submitted after 5:00PM Eastern Timezone (America) on a weekday (Monday through Thursday) and before 7:59:59AM Eastern Timezone (America) on a weekday, than the date will be changed to the next business day @ 8:00 AM.
2) if a request was submitted between 5:00 PM on a Friday and before 7:59:59 AM that following Monday, than the time rolls up as noted above.
3) Then, the code needs to check another date field to compare an "accepted" time (within 4 hours of the submitted date or the "new" date).
For example:
If request 001 was submitted 04/17/2013 02:00AM, then its new date will be 04/17/2013 08:00AM.
If request 002 was submitted 04/17/2013 06:45PM, then its new date will be 04/18/2013 08:00AM.
If request 003 was submitted 04/20/2013 05:45AM (this is a Saturday), then its new date will be 04/22/2013 08:00AM.
I have been piecemailing the code together, in hopes that I can bring it all together in the final code.
This is what I have so far (for the date conversion code)
,CASE
WHEN to_date(('DATE_REQUESTED'),'DAY',nls_date_language = English) in ('Friday','Saturday'))
THEN NEXT_DAY(to_date(('DATE_REQUESTED'),'Monday') + 8 / 24)
ELSE DATE_REQUESTED
END as Weekend_Converted
For the code to check if the request was accepted within 4 hours
SELECT RIT_Request_v.*
,CASE
WHEN DATE_ACCEPTED IS NULL THEN 'NOT ACKNOWLEDGED'
WHEN DATE_ACCEPTED > (DATE_REQUESTED + 4 / 24) THEN 'OVER 4 HOURS'
ELSE 'WITHIN 4 HOURS'
END AS Acknowledgement
FROM RIT.RIT_Request_v
WHERE (("DATE_REQUESTED") BETWEEN trunc(sysdate, 'YYYY') AND trunc(sysdate))
As noted in one of my comments below, I updated my code, and am now getting "Invalid identifier" errors -
SELECT RIT_Request_v.*
,CASE WHEN TO_CHAR(DATE_REQUESTED,'D') IN (1,6,7)
THEN NEXT_DAY(DATE_REQUESTED,'MONDAY')
ELSE DATE_REQUESTED + 1 END AS Weekend_Converted
,CASE WHEN DATE_ACCEPTED IS NULL THEN 'NOT ACKNOWLEDGED'
WHEN WEEKEND_CONVERTED IS NULL THEN 'NOT ACKNOWLEDGED'
WHEN DATE_ACCEPTED > (DATE_REQUESTED + 4 / 24) THEN 'OVER 4 HOURS'
WHEN DATE_ACCEPTED > (Weekend_Converted + 4 / 24) THEN 'OVER 4 HOURS'
ELSE 'WITHIN 4 HOURS' END AS Acknowledgement
FROM RIT.RIT_Request_v
WHERE (("DATE_REQUESTED") BETWEEN trunc(sysdate, 'YYYY') AND trunc(sysdate))
AND FORM_ID IN (2011,2014,5007,5036,5039,7007,10000,10001,10005,10007,10011,10024,10025,10029,10032,10033,10034,10035,10036,10037,11011,11013,11999,36001)