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
 

 

Getting a date that 3 months ago from today's date

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
Alexis Sebastian

New User


Joined: 04 Mar 2010
Posts: 38
Location: DC

PostPosted: Mon May 10, 2010 5:43 pm    Post subject: Getting a date that 3 months ago from today's date
Reply with quote

Is it possible to fetch a date which is 3 months beofre from today's date?
For Ex, if today's date is 27/02/2010 - needs to get an output date as 27/11/2009.

Input file is FB, 80 bytes, input date starts at position 10 and ends at position 19.
Back to top
View user's profile Send private message

Shweta12j

New User


Joined: 10 May 2010
Posts: 32
Location: Mumbai

PostPosted: Mon May 10, 2010 7:00 pm    Post subject:
Reply with quote

Hi ,

you can do this using DB2 in your program..
U can test the same by running below query in QMF..

SELECT DATE('27.02.2010') - 3 MONTH
FROM UU01.TMG_BUSSCNT_VERS

where UU01.TMG_BUSSCNT_VERS is a table name.

Regards,
Shweta.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Tue May 11, 2010 1:16 am    Post subject:
Reply with quote

Alexis Sebastian,

SORT products do NOT have the capability of subtracting months from a given date. If you are Ok with subtracting 90 days then I can show you a way to do it.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10211
Location: italy

PostPosted: Tue May 11, 2010 2:03 am    Post subject: Reply to: Getting a date that 3 months ago from today's date
Reply with quote

to add my 2€
You asked for a quick and dirty solution, if You tell the exact requirement we might come up with some reasonable suggestions

the date computation rules are a bit tricky ( especially for financial related issues )

adding and subtracting months implies that the requirement is well understood and approved at the proper level

the most common issue is when the target month has less days than the current mont

for example when subtracting 1 month from march 30/31 what does Your organization expect
the common approach is to give back the LAST day of the target month
so it should give back feb 28 or feb 29 depending on the leapness of the target year
but they must be awareof the issue

Shweta.
fro a strictly technical point of view a db2 query does certainly provide the result
but is a poor practice to put a db2 dependency just for a simple date subtraction/addition
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue May 11, 2010 2:36 am    Post subject:
Reply with quote

adding to enrico's comments about decent design and proper usage of tools/utilities:

1. If the date in the file is supposed to be today's date (current date),
then it was calculated, created or placed in the file somehow.
Why not calculate the second date (3 months ago) during the same process?

2. when doing date calculations with db2, and the date is external to a db2 column,
use sysibm.sysdummy1 instead of an existing user table.
then you don't have worry about authorizations and/or qualifiers.
If it will always be today's date, use CURRENT_DATE.

3. to derive the date using db2, Use the DSNTEP2 or DSNTEP4 programs to execute SQL statements dynamically.
The SYSIN can be concatenated ds (or pds members)
each containing the necessary info,
and the one which contains the date can be designated with substitution variables set within the jcl of the step, thus pointing to any date you wish.

Code:

//SYSIN  dd=hlq.mlq.llq.(mbr1), disp=shr
//       dd=hlq.mlq.llq.(&mbrdte), disp=shr
//       dd=hlq.mlq.llq.(mbr2), disp=shr

where
  • mbr1 contains the appropriate sql up to and including the ( preceding the date
  • &mbrdte contains the date for todays run
  • mbr2 contains the rest of the sql starting with the )
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10211
Location: italy

PostPosted: Tue May 11, 2010 3:36 am    Post subject: Reply to: Getting a date that 3 months ago from today's date
Reply with quote

good catch Dick ! to use dsntep for producing dates


I do not have a db2 available right now...
could You please post some results...
just to see how it looks like
and to see what additional formatting should be carried along !

thank You !

cheers
enrico
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Tue May 11, 2010 10:04 pm    Post subject:
Reply with quote

dbzTHEdinosauer,

I would NOT recommend using DSNTEP2 or DSNTEP4 to create the dates for the following reasons

1. The output from DSNTEP2 has an LRECL of 133 bytes. You cannot override that. If you are planning to use the date created as symnames to DFSORT then it is NOT valid

2. The output from DSNTEP2 is more like a report with headers and other stuff.

I prefer using DSNTIAUL which gives you more flexibility to create data which will be used later

Kolusu
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue May 11, 2010 11:40 pm    Post subject:
Reply with quote

Skolusu wrote:
I prefer using DSNTIAUL which gives you more flexibility to create data which will be used later


good point, Kolusu
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 -> DFSORT/ICETOOL 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