Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Date calculation in PL/I

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler
View previous topic :: :: View next topic  
Author Message
anjani shanker

New User


Joined: 26 Jan 2007
Posts: 37
Location: USA

PostPosted: Thu Nov 27, 2008 1:32 am    Post subject: Date calculation in PL/I
Reply with quote

Hi,

I have a scenario in which i have a date value, say X.

X is usually any date which is in the middle of current month. No I have an array of size 5 in which i need to store a date which is would be last date of every next month. Like:

X= 11/15/2008

then array should contain :
A(1) = 12/31/2008
A(2) = 01/31/2009
A(3) = 02/28/2009
and so on ...

Plz help me with how could this be implemented in PL1.
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7932
Location: Bellevue, IA

PostPosted: Thu Nov 27, 2008 2:17 am    Post subject:
Reply with quote

You could write your own function to do this in PL/1. Pass in X and get back the array -- but I don't know of any intrinsic functions to do this kind of date manipulation. If you have trouble with the code once you've written it, please let us know.
Back to top
View user's profile Send private message
PeD

Active User


Joined: 26 Nov 2005
Posts: 456
Location: Belgium

PostPosted: Thu Nov 27, 2008 3:26 am    Post subject:
Reply with quote

Quote:
No I have an array of size 5
?? What is this?
Back to top
View user's profile Send private message
Garry Carroll

Active Member


Joined: 08 May 2006
Posts: 991
Location: Dublin, Ireland / Edinburgh, Scotland

PostPosted: Thu Nov 27, 2008 3:01 pm    Post subject:
Reply with quote

Define two arrays, one for standard years and one for leap-years. Each array to contain the last possible date for each month in that year-type.

Now, decide which of these arrays to use based on the YYYY portion of your date in X. Next, use the MM portion of the date in X to determine a starting point in that array.

Populate your array of 5 elements starting at this point.

You'll need to code around year-end, deciding whether next year is leap-year or not....

Hope this helps,
Garry.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10211
Location: italy

PostPosted: Thu Nov 27, 2008 3:14 pm    Post subject: Reply to: Date calculation in PL/I
Reply with quote

to make it general...

split the source date in the components, year and month using the substring function and the concatenate function

after this buid an auxiliary array with the char representation of the first day of the neded month + 1

for Your sample 11/15/2008

aux(1) = "20090101"
aux(2) = "20090201"
aux(3) = "20090301"
aux(4) = "20090401"
aux(5) = "20090501"

after this you can build the final array by using the CEEDATE and CEEDAYS
LE functions

last day of month x = CEEDATE(CEEDAYS(first_day_of_month_x_plus_one)-1))

look at the manual for the proper use of CEEDATE family functions
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts TOT & DATE parameter in ICEMAN hemanthj642 DFSORT/ICETOOL 4 Mon Nov 14, 2016 5:19 am
This topic is locked: you cannot edit posts or make replies. How to pass the previous month date i... Suganya87 DFSORT/ICETOOL 5 Mon Oct 31, 2016 4:13 pm
This topic is locked: you cannot edit posts or make replies. Get correct date and time when curren... balaji81_k DB2 24 Fri Oct 14, 2016 10:40 pm
No new posts Change date (DD/MM/YY) in 2nd record ... uday kiran DFSORT/ICETOOL 12 Wed Sep 07, 2016 10:57 pm
No new posts Add system date inside of a PS file a... pramitdas DFSORT/ICETOOL 5 Sun Aug 28, 2016 12:06 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us