Reputation: 793
We send mailouts every evening using SQL. For this in particular we'd like to send a reminder every 3 days, but I have absolutely no idea how to do this, or if it's even possible?
Here's my code:
SELECT *
FROM table
WHERE status = 'pending'
AND ( date_created = sysdate - 3
OR date_created = sysdate - 6
OR date_created = sysdate - 9 )
Something to that effect, but a nicer way of coding it and also a more effective one that won't require me to go all the way into the hundreds! ^_^
Thanks
Upvotes: 3
Views: 2316
Reputation: 88378
Try
SELECT *
FROM table
WHERE status = 'pending'
AND MOD(sysdate-date_created, 3) = 0
Information on Oracle MOD: http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions088.htm
Upvotes: 7