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 

Sub 18 days from date timestamp

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


Joined: 19 Feb 2009
Posts: 50
Topics: 10

PostPosted: Sat Feb 19, 2011 4:27 am    Post subject: Sub 18 days from date timestamp Reply with quote

My requirement is to subtract 10 days from DATE timestamp. will it be possible in DFSORT.

datetimestamp x(26).
Position 34 to 59 .
LRECL 80 FB.
Value: 2011-02-18-11.01.54.972002

Iam trying to do in the following way. But I am incorrect. can anyone pls help me in this.
Code:
SORT FIELDS=COPY                                                   
OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(34:34,10,UFF,TO=ZD,LENGTH=8)),
       IFTHEN=(WHEN=INIT,BUILD=(1,33,34:34,8,Y4T,SUBDAYS,+18,   
                                TOGREG=Y4T(-),46,35))         

_________________
regds,
radhakrishnan v
Back to top
View user's profile Send private message
radkrish82
Beginner


Joined: 19 Feb 2009
Posts: 50
Topics: 10

PostPosted: Sat Feb 19, 2011 6:03 am    Post subject: Reply with quote

I forgot SUBDAYS doesnt work in my shop. sorry for the trouble.
Back to top
View user's profile Send private message
radkrish82
Beginner


Joined: 19 Feb 2009
Posts: 50
Topics: 10

PostPosted: Sat Feb 19, 2011 9:11 am    Post subject: Reply with quote

I got it atlast by converting Greg date to Julian and subtracting Julian by the number of days and then convert it back to Greg date. It works fine.

Thanks.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Tue Feb 22, 2011 11:21 am    Post subject: Reply with quote

radkrish82 wrote:
I got it atlast by converting Greg date to Julian and subtracting Julian by the number of days and then convert it back to Greg date. It works fine.

Thanks.


Glad you figured it out. However make sure that you validated the dates when subtraction of Julian date results in 0 or a negative value.(ex: Jan 1- Jan 18th dates) You need to check if the prior year is a leap year and perform the arithmetic accordingly. Good Luck
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
radkrish82
Beginner


Joined: 19 Feb 2009
Posts: 50
Topics: 10

PostPosted: Wed Feb 23, 2011 4:26 am    Post subject: Reply with quote

I am running from 16th Jan to April. Can you please tell me how to validate prior leap year conditions.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Wed Feb 23, 2011 1:10 pm    Post subject: Reply with quote

radkrish82 wrote:
I am running from 16th Jan to April. Can you please tell me how to validate prior leap year conditions.


Radkrish82,

How did you the get right results when you subtracted 18 days from 16th Jan without performing the leap year check?

Anyway use the following control cards which will give you the desired results.

Code:

//SYSIN    DD *                                                 
  SORT FIELDS=COPY                                               
  INREC IFOUTLEN=80,IFTHEN=(WHEN=INIT,                           
  OVERLAY=(81:34,10,UFF,M11,LENGTH=8,81,8,Y4T,TOJUL=Y4T,         
           93:93,3,ZD,SUB,+18,ZD,LENGTH=3)),                     
  IFTHEN=(WHEN=(93,3,ZD,LE,0),                                   
  OVERLAY=(89:89,4,ZD,SUB,+1,M11,LENGTH=4,96:89,4,C'1231',       
           104:96,8,Y4T,TOJUL=Y4T,                               
           093:93,3,ZD,ADD,108,3,ZD,EDIT=(TTT),                 
           034:89,7,Y4T,TOGREG=Y4T(-))),                         
  IFTHEN=(WHEN=NONE,OVERLAY=(034:89,7,Y4T,TOGREG=Y4T(-)))       
                                                                 
//*

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


Joined: 19 Feb 2009
Posts: 50
Topics: 10

PostPosted: Wed Feb 23, 2011 9:06 pm    Post subject: Reply with quote

Thanks, Kolusu. We got this requirement only on this month and started running from this month. Next year, we will be running from Jan month. Hence problem didnt arrived for this year. For sure, it would had given wrong results next year.
I need to add the leap year fix asap. Thanks for your help, Kolusu.
Back to top
View user's profile Send private message
papadi
Supermod


Joined: 20 Oct 2009
Posts: 594
Topics: 1

PostPosted: Wed Feb 23, 2011 10:34 pm    Post subject: Reply with quote

This is what is known as a "time bomb". . . With insufficient testing, you may have many of these buried about. . . They might not all be related to leap year.

Everything insufficiently tested is possibly just waiting to cause damage/disruption . . .
Which will usually happen at the worst possible time. . . bonk
_________________
All the best,

di


Last edited by papadi on Thu Feb 24, 2011 2:53 pm; edited 2 times in total
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Thu Feb 24, 2011 1:18 am    Post subject: Reply with quote

radkrish82 wrote:
Thanks, Kolusu. We got this requirement only on this month and started running from this month. Next year, we will be running from Jan month. Hence problem didnt arrived for this year. For sure, it would had given wrong results next year.
I need to add the leap year fix asap. Thanks for your help, Kolusu.


Wow don't you test for all the possible scenarios? on second thoughts it is basic testing of the data. Just because you did not have the test data , you assumed that it would work?
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
radkrish82
Beginner


Joined: 19 Feb 2009
Posts: 50
Topics: 10

PostPosted: Thu Feb 24, 2011 9:41 am    Post subject: Reply with quote

well, I agree. yes. we have to test all possible scenarios.
Its a scenario in support where we needed quick fix for an issue, we went on to make sure it runs fine till April of this year as an adhoc request. If its via a Design/developement request rather than adhoc, then we definitely have time and had explored every test scenarios(century leap year,regular leap year) in place and go in processed way SDLC. Client is more of correct fix at that time when it comes to an adhoc. Wish my client didnt read this post Smile
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Thu Feb 24, 2011 12:12 pm    Post subject: Reply with quote

radkrish82 wrote:
well, I agree. yes. we have to test all possible scenarios.
Its a scenario in support where we needed quick fix for an issue, we went on to make sure it runs fine till April of this year as an adhoc request. If its via a Design/developement request rather than adhoc, then we definitely have time and had explored every test scenarios(century leap year,regular leap year) in place and go in processed way SDLC. Client is more of correct fix at that time when it comes to an adhoc. Wish my client didnt read this post Smile


Radkrish82,

All I can say is you need to change your approach.
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities 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