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 Date to Absolute Date

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

New User


Joined: 19 Oct 2015
Posts: 10
Location: UK

PostPosted: Tue Dec 15, 2015 3:57 pm    Post subject: Convert Date to Absolute Date
Reply with quote

Hi Guys, wondering if you can help.

Is there any way of converting a date (yyyymmdd) into an Absolute Date, I work for a bank and we use an absolute date in quite a lot of programs, but just wondered if there was any way of converting it in sort or icetool ?

We define the absolute date as the number of days since 1st Jan 1900

So today (15th Dec 2015 -20151215) would be 42322

cheers

Steve
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7240

PostPosted: Tue Dec 15, 2015 4:52 pm    Post subject: Reply to: Convert Date to Absolute Date
Reply with quote

You want to have a look at DATEDIFF.

You're going to have to put the 1900 date into a temporary extension to the record to have access to it.

Exactly the best way to use it depends on exactly what you want to do, both generally and case-by-case perhaps as well.
Back to top
View user's profile Send private message
Steve Ironmonger

New User


Joined: 19 Oct 2015
Posts: 10
Location: UK

PostPosted: Tue Dec 15, 2015 5:38 pm    Post subject: Reply to: Convert Date to Absolute Date
Reply with quote

Hi Bill,

As an example I want to convert

20151215
to
42322

42322 being the number of days since 1st Jan 1900

or
19000131
to
00031
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7240

PostPosted: Tue Dec 15, 2015 6:20 pm    Post subject: Reply to: Convert Date to Absolute Date
Reply with quote

Here's an example with converting a date to a number with DATEDIFF. To save adjusting by one, I used 18991231 not 19000101.
Code:

  OPTION COPY
  INREC OVERLAY=(10:C'18991231',
                 20:1,8,Y4T,
                  DATEDIFF,
                   10,8,Y4T)
                               
//SORTIN   DD *
19000131
20151215


The output is:

Code:
19000131 18991231  +0000031
20151215 18991231  +0042352


An eight-position field with a leading sign is created as the result of DATEDIFF. The + indicates that the second field is larger (- would indicate the opposite). Offset by three to get your desired result (23,5,CH for instance).

You need to temporarily "extend" each record to contain the base date, and the resultant difference. You can abut the fields, I've just left padding to more easily read the output.

For a fixed-length record, you extend after the end of the record. For a variable-length record extend at the beginning, using BUILD:

Code:
  INREC BUILD=(1,4,C'18991231',8X,5)


You have to return the data to its original size after using the DATEDIFF (can be in OUTREC or OUTFIL).
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 How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts Convert +9999999999999.99 to S9(12)V9(3) vnktrrd DFSORT/ICETOOL 8 Thu Nov 17, 2016 8:15 pm
This topic is locked: you cannot edit posts or make replies. Db2 SQL query to convert rows into co... subratarec DB2 5 Thu Nov 17, 2016 4:51 pm
No new posts TOT & DATE parameter in ICEMAN hemanthj642 DFSORT/ICETOOL 4 Mon Nov 14, 2016 5:19 am
No new posts convert PD to ZD ram_vizag DFSORT/ICETOOL 5 Sat Nov 05, 2016 3:06 am


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