View previous topic :: View next topic |
Author |
Message |
tcurrier Intermediate
Joined: 10 Feb 2006 Posts: 188 Topics: 68
|
Posted: Sat May 05, 2007 6:04 am Post subject: determine Monday and subtract 3 days from current date ? |
|
|
I'm trying to set up an automated query that runs every morning, but it needs to check the prior day's date, so I did the following:
Code: | AND E.DATE_PROCESSED = (CURRENT DATE - 1 DAY) |
This will work fine, except that Friday's report doesn't run until Monday morning, so I need to subtract 3 days if the report is being run on Monday, instead of 1 day.
Can anyone help out with this ?
Thanks. |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Sat May 05, 2007 9:33 am Post subject: |
|
|
tcurrier,
Try this untested query. You can run it on any day and it will still give you the results for a business day (mon-fri)
Code: |
AND E.DATE_PROCESSED = (CURRENT DATE - (CASE DAYOFWEEK(CURRENT DATE)
WHEN 1 THEN INT(2)
WHEN 2 THEN INT(3)
ELSE INT(1) END) DAYS)
|
Dayofweek scalar function is explained here
http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/DSNSQH11/3.2.20?SHELF=&DT=20010718164132&CASE=
Hope this helps...
Cheers
Kolusu
Ps: I am hoping that this question is not posted else where. If it is posted else where then you will loose the privileges to post on this board as this is not the first time you did that. Pick a board of your choice, it does not matter which one it is and wait for a min of 8 hours to post it on another helpboard. your prior question of lpar was deleted for the same reason. _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
tcurrier Intermediate
Joined: 10 Feb 2006 Posts: 188 Topics: 68
|
Posted: Sat May 05, 2007 12:52 pm Post subject: |
|
|
It works perfect.... Thank you very much ...
And thanks for the P.S. about posting in two different forums.... I don't post very often, so I wasn't sure if that was allowed or not.... But thanks for clearing it up... |
|
Back to top |
|
 |
|
|