Question

Normally I only show a record, if the actual date is one year later than the date in the database. How can I check if that day is a friday and then show also the records with the date of the saturday or sunday?

For example: Friday the 13th before one year. I will also show records from 14th(saturday) and 15th(sunday)

where myDate.arrival < TRUNC (SYSDATE) -365)

That's my actual statement.

Was it helpful?

Solution 2

Where Mydate.Arrival < Trunc (Sysdate) - 365
Or (to_char(Mydate.Arrival, 'D') = 6 AND Mydate.Arrival < Trunc (Sysdate) -363)

This way, you can check if that day is a Friday (6th day of week) and then select records whose Arrival value is less than sysdate - 363 (2 more days - Saturday and Sunday - included).

OTHER TIPS

You need a condition in case. Check the example below for reference:

WHERE txnday in 
  CASE to_char(sysdate, 'Day')
      WHEN 'Friday' THEN // Include condition for Sat and Sun as well
      ELSE // Include condition for only that day
  END
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top