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
 

 

Convert current date to last month's

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
lekshmi_ci

New User


Joined: 14 Mar 2007
Posts: 60
Location: Thiruvananthapuram

PostPosted: Mon Sep 24, 2007 10:22 am    Post subject: Convert current date to last month's
Reply with quote

Can anyone help me in solving this issue:

I want to convert the date (used in the record) to last month's. For eg if the date is 24th Sep, I need to change it to 24th Aug. The no. of records is huge and each record has a date field.

Thanks
LC
Back to top
View user's profile Send private message

Devzee

Active Member


Joined: 20 Jan 2007
Posts: 684
Location: Hollywood

PostPosted: Mon Sep 24, 2007 11:21 am    Post subject:
Reply with quote

Is it just subtract one to your month in the record?

What happens if the date is 03/31/2007 the new date should be 02/28/2007 right?
What happens if the date is 09/30/2007 the new date should be 08/30/2007 or 08/31/2007?

I believe you should use date routine if available in your site.
Back to top
View user's profile Send private message
lekshmi_ci

New User


Joined: 14 Mar 2007
Posts: 60
Location: Thiruvananthapuram

PostPosted: Mon Sep 24, 2007 11:27 am    Post subject:
Reply with quote

yep devzee . u r absolutely right
we need to subtract one from the month
if u cn provide me tht piece of code, i would be grateful.
Rexx is totally new to me.
I started learning tht.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10256
Location: italy

PostPosted: Mon Sep 24, 2007 11:34 am    Post subject: Reply to: to convert current date to last month's
Reply with quote

Quote:
yep devzee . u r absolutely right


It looks like You read only the first line of devzee reply !

What format has the date ?
subtracting one from the month with brute force is let's say OK if the date string contains only the year and the month,
will result in a serious application troubles if the dtae string contains also the day

regards

e.s
Back to top
View user's profile Send private message
lekshmi_ci

New User


Joined: 14 Mar 2007
Posts: 60
Location: Thiruvananthapuram

PostPosted: Mon Sep 24, 2007 11:40 am    Post subject:
Reply with quote

I totally agree with devzee. The date to be converted is as he has mentioned. If the date is 09/30/2007 then the new date should be 08/30/2007
we need to handle two more additional conditions in the program:
if the date is 03/31/2007 and
if the date is 09/30/2007
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10256
Location: italy

PostPosted: Mon Sep 24, 2007 11:45 am    Post subject: Reply to: to convert current date to last month's
Reply with quote

Quote:
I totally agree with devzee.


OK, OK....
You keep agreeing with devzee, but it is the application logic which should tell what to do when the current day is not in the previous month !

The only thing we can remark, from the ino You posted, is to flag the request as ILLOGIC..

regards

e.s
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2360
Location: Israel

PostPosted: Mon Sep 24, 2007 11:50 am    Post subject:
Reply with quote

Why are you doing it with REXX, if "The no. of records is huge " as you said? For your needs, I believe Assembler should be the choice.

O.
Back to top
View user's profile Send private message
lekshmi_ci

New User


Joined: 14 Mar 2007
Posts: 60
Location: Thiruvananthapuram

PostPosted: Mon Sep 24, 2007 12:01 pm    Post subject:
Reply with quote

can you suggest me a code if i want to change the file name having a date to another file name having next month's date.
For eg, if the filename is aa20071212, i need the filename to be changed to aa20071111.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10256
Location: italy

PostPosted: Mon Sep 24, 2007 12:08 pm    Post subject: Reply to: to convert current date to last month's
Reply with quote

Quote:
can you suggest me a code if i want to change the file name having a date to another file name having next month's date.
For eg, if the filename is aa20071212, i need the filename to be changed to aa20071111.


Now You ask to change the file name, nothing wrong with that;
but the logic flaw is still there;

WHAT IF the destination month does not have the day Yo ask for ???

please clarify or desist

regards

e.s
Back to top
View user's profile Send private message
lekshmi_ci

New User


Joined: 14 Mar 2007
Posts: 60
Location: Thiruvananthapuram

PostPosted: Mon Sep 24, 2007 12:20 pm    Post subject:
Reply with quote

if the day doesnt exist for tht month, then put one day before
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10256
Location: italy

PostPosted: Mon Sep 24, 2007 12:21 pm    Post subject: Reply to: to convert current date to last month's
Reply with quote

Quote:
f the day doesnt exist for tht month, then put one day before


That's a nice way of getting duplicate records and/or duplicate file names!

regards

e.s
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2360
Location: Israel

PostPosted: Mon Sep 24, 2007 2:59 pm    Post subject:
Reply with quote

lekshmi_ci -

No one is going to "give you the code". People here will help you to write your own code, as long as you make your requirements clear. Till now, I believe you confused us all...

O.
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1228
Location: Israel

PostPosted: Wed Sep 26, 2007 2:52 pm    Post subject:
Reply with quote

If the data resides in a DB2 table, you can do:
UPDATE table SET MYDATE = MYDATE - 1 MONTH

If it's not DB2, certainly SORT or SYNCSORT can do the job for you,
faster and better than any REXX or Assembler program.
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 -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Validate date and numeric fields and ... Rick Silvers DFSORT/ICETOOL 6 Thu May 11, 2017 6:51 pm
No new posts SMTP the current generation number of... Jyothi Kulunde JCL & VSAM 4 Thu May 04, 2017 4:08 pm
No new posts LISTIDR compiled date/time jerryte IBM Tools 3 Thu Apr 20, 2017 7:37 pm
No new posts SUBSTR for Date functions Shaheen Shaik DB2 4 Thu Apr 06, 2017 2:14 pm
No new posts Date and time format in CICS Chandru3183 CICS 2 Sat Mar 18, 2017 12:46 pm


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