IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

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


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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
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
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

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Tue May 11, 2010 2:03 am
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
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

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Tue May 11, 2010 3:36 am
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Need to convert date format DFSORT/ICETOOL 20
No new posts Need help to append a date&tsp at... DFSORT/ICETOOL 9
No new posts Fetch data from programs execute (dat... DB2 3
Search our Forums:

Back to Top