View previous topic :: View next topic
|
Author |
Message |
lekshmi_ci
New User
Joined: 14 Mar 2007 Posts: 60 Location: Thiruvananthapuram
|
|
|
|
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 |
|
|
Devzee
Active Member
Joined: 20 Jan 2007 Posts: 684 Location: Hollywood
|
|
|
|
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 |
|
|
lekshmi_ci
New User
Joined: 14 Mar 2007 Posts: 60 Location: Thiruvananthapuram
|
|
|
|
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 |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10886 Location: italy
|
|
|
|
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 |
|
|
lekshmi_ci
New User
Joined: 14 Mar 2007 Posts: 60 Location: Thiruvananthapuram
|
|
|
|
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 |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10886 Location: italy
|
|
|
|
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 |
|
|
ofer71
Global Moderator
Joined: 27 Dec 2005 Posts: 2358 Location: Israel
|
|
|
|
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 |
|
|
lekshmi_ci
New User
Joined: 14 Mar 2007 Posts: 60 Location: Thiruvananthapuram
|
|
|
|
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 |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10886 Location: italy
|
|
|
|
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 |
|
|
lekshmi_ci
New User
Joined: 14 Mar 2007 Posts: 60 Location: Thiruvananthapuram
|
|
|
|
if the day doesnt exist for tht month, then put one day before |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10886 Location: italy
|
|
|
|
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 |
|
|
ofer71
Global Moderator
Joined: 27 Dec 2005 Posts: 2358 Location: Israel
|
|
|
|
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 |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
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 |
|
|
|