MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Hardcoding saturday date of every month

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
THRIVIKRAM
Beginner


Joined: 03 Oct 2005
Posts: 70
Topics: 34

PostPosted: Tue May 30, 2006 4:48 am    Post subject: Hardcoding saturday date of every month Reply with quote

Hello,

I have the following requirement.

I have a table X which will be updated by jobs that run daily.The rows updated on a particular day can be known from
LST_UPDT_DT colum of the X table.
Now, I have other monthly job which runs last saturday. This job retrieves all the rows that were updated since previous
run(last Saturday of previous month) to current month run(last saturday of this month).
The condition used is X.LST_UPDT_DT > '04/29/2006'.(for example)
But,every time we are hardcoding the Saturday date of previous month.

Is there any way by which we can overcome this burden. I mean,the condition must be such that
X.LST_UPDT_DT > [some quantity] , where [some quantity] should reflect the last saturday of previous month.

Thanks,
Thrivirkam.
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Tue May 30, 2006 5:26 am    Post subject: Reply with quote

THRIVIKRAM,
Quote:

But,every time we are hardcoding the Saturday date of previous month.


Here is a sql which will give you last saturday of the last month

Code:

SELECT DATE(NEXT_DAY(LAST_DAY(CURRENT DATE - 1 MONTH) - 7 DAYS,'SAT'))
  FROM SYSIBM.SYSDUMMY1;                                             


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
THRIVIKRAM
Beginner


Joined: 03 Oct 2005
Posts: 70
Topics: 34

PostPosted: Wed May 31, 2006 12:47 am    Post subject: Hardcoding saturday date of every month Reply with quote

Thanks Kolusu,

But Could you please tell how this code is working.
I need this because, when I try giving the date manually(just for testing in the QMF) instead of Current date its throwing the error
"Argument '2' of scalar function '-' is invalid."

Thnx for your time.
Back to top
View user's profile Send private message Send e-mail
acevedo
Beginner


Joined: 03 Dec 2002
Posts: 127
Topics: 0
Location: Europe

PostPosted: Wed May 31, 2006 1:23 am    Post subject: Reply with quote

then try
Code:


SELECT CURRENT DATE                                                     
      ,DATE(NEXT_DAY(LAST_DAY([color=red]DATE[/color]('2006-05-31') - 1 MONTH) -7 DAYS,'SAT'))
  FROM SYSIBM.SYSDUMMY1;
Back to top
View user's profile Send private message
shekar123
Advanced


Joined: 22 Jul 2005
Posts: 528
Topics: 90
Location: Bangalore India

PostPosted: Wed May 31, 2006 1:42 am    Post subject: Reply with quote

acevedo,

You have clearly given the query to know the current date as well the desired result
Code:

SELECT CURRENT DATE,DATE(NEXT_DAY(LAST_DAY(DATE('2006-05-31') - 1 MONTH) - 7 DAYS,'SAT'))
FROM SYSIBM.SYSDUMMY1;                                                       

OUTPUT
Code:

 COL1        COL2       
 ----------  ----------
 2006-05-31  2006-04-29

THRIVIKRAM,

You were getting error because you were trying to do '2006-05-31' - 1 MONTH , if you give DATE('2006-05-31') - 1 MONTH , then you will acheive the correct result because of compatibility.
_________________
Shekar
Grow Technically
Back to top
View user's profile Send private message
THRIVIKRAM
Beginner


Joined: 03 Oct 2005
Posts: 70
Topics: 34

PostPosted: Wed May 31, 2006 2:29 am    Post subject: Hardcoding saturday date of every month Reply with quote

Yes,Its working!!!

Actually I overlooked that point.

Thanks.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group