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
 

 

To add 10 minutes to TIMESTAMP

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

New User


Joined: 16 Apr 2008
Posts: 86
Location: Bangalore

PostPosted: Tue Nov 10, 2009 4:41 pm    Post subject: To add 10 minutes to TIMESTAMP
Reply with quote

Hi,
I need the time stamp which is 10 minutes ahead of the time stamp in the input fie.
Say I have
Code:

2003-02-19-11.05.01
in the input file
I should get
Code:

2003-02-19-11.15.01

in the output file

Even the date can change if the input time between 23.50.00 to 24.00.00

Can this be achieved using DFSORT.

Regards,
Balu
Back to top
View user's profile Send private message

enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10201
Location: italy

PostPosted: Tue Nov 10, 2009 4:48 pm    Post subject: Reply to: To add 10 minutes to TIMESTAMP
Reply with quote

apart the technical issue..
any audit/security/legal_compliance group of <any> organization would define what <you> are trying to do as a <forgery>

is <anybody> in Your organization aware of that

for example ...
what if the timestamp has been printed on some already delivered report/accounting slip !!
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Tue Nov 10, 2009 5:01 pm    Post subject:
Reply with quote

Given Enricos reference to legal issues, I for one would certainly like to know the reason for such a request.
Back to top
View user's profile Send private message
vvmanyam

New User


Joined: 16 Apr 2008
Posts: 86
Location: Bangalore

PostPosted: Tue Nov 10, 2009 5:45 pm    Post subject:
Reply with quote

Hi,

Quote:

any audit/security/legal_compliance group of <any> organization would define what <you> are trying to do as a <forgery>


With out knowing why exactly I am asking this question, I think this is unfair to say

Quote:

is <anybody> in Your organization aware of that

Yes, every body is aware of this. we figured out many ways for this requirement.
I thought let me give a try here. if not possible here, then thinking of writing a new cobol program.

You really want to know the requirement, here it is!!
In IDMS, to extract the Print Logs from Data Base dump messages, we need to pass the start and end time stamp as input to the utility 'IDMSBCF'. We need to extract each 10 minutes data in to one dataset. So, we have to pass 2 time stamps (current and 10 mins back time stamps) and schedule the job for every 10 minutes. So, I need these 2 times in a file in 2 different rows.

Enrico,
Do you/audit/security/legal_compliance group see any issues here, Please let me know !!

Regards,
Balu
Back to top
View user's profile Send private message
Ronald Burr

Active User


Joined: 22 Oct 2009
Posts: 293
Location: U.S.A.

PostPosted: Tue Nov 10, 2009 5:57 pm    Post subject:
Reply with quote

You say that you are thinking of writing a new cobol program if it is not possible to do what you want, using the utility you specify.

What if you can NOT do it via DFSORT, but you COULD do it via some OTHER utility that is far easier than writing a new cobol program?

Namely, you have severely limited the methods to achieve your goal to only two - DFSORT and cobol. Have you, or would you consider other options?

Look at your signature block and think about it.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10201
Location: italy

PostPosted: Tue Nov 10, 2009 6:03 pm    Post subject: Reply to: To add 10 minutes to TIMESTAMP
Reply with quote

Quote:
With out knowing why exactly I am asking this question, I think this is unfair to say

given the original post wording I have nothing to regret about my answer
learn to post better description of Your issues and nobody will be concerned about legal issues
( whenever they do not apply )

if You had posted something like ...
I need to create two timestamps for data extraction
would have saved lots of confusion and useless network traffic
I would not have even cared to answer

Quote:
Do you/audit/security/legal_compliance group see any issues here, Please let me know !!

just drop the condescending tone please ...
I made a serious remark, out of events that I have seen happen in real life

but it looks like You did not appreciate my concerns ...
in this case the words of Rhett Butler apply icon_biggrin.gif
Back to top
View user's profile Send private message
vvmanyam

New User


Joined: 16 Apr 2008
Posts: 86
Location: Bangalore

PostPosted: Tue Nov 10, 2009 6:34 pm    Post subject:
Reply with quote

With knowledge that I have, all I can think of only these options JOb with COBOL program or a SORT step or Rexx pgm.

Rexx is not accepted in our production.
So, I am left with other 2.
But If you have any other ideas, I am happy to at least know about them if not implement.

Thanks,
Balu
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Wed Nov 11, 2009 12:25 am    Post subject:
Reply with quote

DFSORT does not have any built-in functions for subtracting 10 minutes from a timestamp.

If you can determine how to do this arithmetically with a program, you could probably do it with DFSORT's arithmetic functions as well. Kolusu is better at this kind of thing then I am, but he's on vacation today.
Back to top
View user's profile Send private message
Ronald Burr

Active User


Joined: 22 Oct 2009
Posts: 293
Location: U.S.A.

PostPosted: Wed Nov 11, 2009 3:27 am    Post subject:
Reply with quote

There should be a way to use a standard utility ( or DFSORT ) to read the first timestamp, imbed it into a generated DB2 SELECT statement that does timestamp arithmetic to add 10 minutes, and then pass that generated SELECT statement to a DB2 Utility ( Batch SPUFI?, DSNUTILB?, DSNTEP2? ) to output the second timestamp, and follow that with a third utility ( or DFSORT ) step to reformat the output timestamp back into the format you want/need.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Wed Nov 11, 2009 5:55 am    Post subject: Reply to: To add 10 minutes to TIMESTAMP
Reply with quote

You will have a date change if the timestamp is (for example) 23:51:00 and you add 10 minutes, you'd be at one minute past midnight, the next day. What if your associated datestamp were the last day of the month or 31 December and the timestamp is as outlined above?

There are considerations to ponder....

Bill
Back to top
View user's profile Send private message
Ronald Burr

Active User


Joined: 22 Oct 2009
Posts: 293
Location: U.S.A.

PostPosted: Wed Nov 11, 2009 6:01 am    Post subject:
Reply with quote

And heaven forbid that the first timestamp was 11:51 p.m. on Feb 28th in a leap year.

All good reasons why I suggested using DB2 to do the date arithmetic - DB2 takes all of those into consideration and yields the "correct" result every time.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10201
Location: italy

PostPosted: Wed Nov 11, 2009 6:26 am    Post subject: Reply to: To add 10 minutes to TIMESTAMP
Reply with quote

strong opinion ...
to bother db2 for a silly date calculation is too much

here a stupid 12liners rexx snippet that will do it ... tested
the relevant code is 12 lines ( looks longer because of the housekeeping for the back and forth test )

Code:
numeric digits 40
tmstmp1  = "2003-02-19-00.05.01"
say tmstmp1
parse var tmstmp1 year "-" mnth "-" days "-" hh "." mm "." ss
btime   = date("b", year || mnth || days ,"s") * ( 3600 * 24 ) + hh * 3600 + mm * 60 + ss
btime   = btime - 600
tmstmp1 = s2t(btime)
say tmstmp1

parse var tmstmp1 year "-" mnth "-" days "-" hh "." mm "." ss
btime   = date("b", year || mnth || days ,"s") * ( 3600 * 24 ) + hh * 3600 + mm * 60 + ss
btime   = btime + 600
tmstmp1 = s2t(btime)
say tmstmp1
exit
s2t:procedure
   parse arg t
   s = right(   ( t // 60 ),                2, "0")
   m = right(   ( t %  60 ) // 60,          2, "0")
   h = right( ( ( t %  60 ) %  60 ) // 24 , 2, "0")
   b =        ( ( t %  60 ) %  60 ) %  24
   d = date("S", b, "B")
   return translate("0123-45-67-89.ab.cd", d||h||m||s, "0123456789abcd")
exit


from the first timestamp it will subtract 10 minutes ( delta expressed in seconds )

and it will add back to the result the same number of seconds

it works for an arbitrary seconds delta for the validity range of the REXX date function
tested for the leap year case icon_biggrin.gif
Back to top
View user's profile Send private message
Ronald Burr

Active User


Joined: 22 Oct 2009
Posts: 293
Location: U.S.A.

PostPosted: Wed Nov 11, 2009 6:32 am    Post subject:
Reply with quote

On Nov 10th at 8:04 a.m. vvmanyam wrote:

"Rexx is not accepted in our production".

That's why I didn't propose a REXX solution.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10201
Location: italy

PostPosted: Wed Nov 11, 2009 6:39 am    Post subject: Reply to: To add 10 minutes to TIMESTAMP
Reply with quote

I can read also and I posted the snippet to show that it is not necessary to bother db2 for such a simple thing icon_biggrin.gif

the same result can be obtained by using the cobol functions
integer of date and date of integer

integer of date <==> date("b",<date_string>,"s")
date of integer <==> date("s",<date_inte>,"b")

the coding is much the same , the longest part is the declarative section

shoul take no more than half an hour to implement it
Back to top
View user's profile Send private message
kaushik8205

New User


Joined: 10 Nov 2006
Posts: 49
Location: Canada

PostPosted: Wed Nov 11, 2009 1:57 pm    Post subject: Reply to: To add 10 minutes to TIMESTAMP
Reply with quote

Posting solutions which are not acceptable only increases the volume of topic.

Balu, I would suggest to do a COBOL program since it helps in better understanding the requirement and reusability will be more.
Also if you are using DB2, then you will have to make sure that jobs are executed in DB2 supported environment.

Thanks.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10201
Location: italy

PostPosted: Wed Nov 11, 2009 2:13 pm    Post subject: Reply to: To add 10 minutes to TIMESTAMP
Reply with quote

Quote:
Posting solutions which are not acceptable only increases the volume of topic.


did You ever hear about prototyping....
verify the correcteness of an approach/algorithm in a simple fashion
in order to implement afterwards in a <more suitable> way icon_biggrin.gif
Back to top
View user's profile Send private message
Ronald Burr

Active User


Joined: 22 Oct 2009
Posts: 293
Location: U.S.A.

PostPosted: Wed Nov 11, 2009 7:52 pm    Post subject:
Reply with quote

This Link points to a COBOL example using LE services to do date/time arithmetic. A little modification to add input/output files might get the job done.
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Wed Nov 11, 2009 11:14 pm    Post subject: Reply to: To add 10 minutes to TIMESTAMP
Reply with quote

vvmanyam,

FWIW here is a DFSORT solution which will add 10 minutes to the given date. It considers leap years and month ends and also year end.

Code:

//STEP0100 EXEC PGM=SORT                                             
//SYSOUT   DD SYSOUT=*                                               
//SORTIN   DD *                                                     
2009-11-11-14.10.01                                                 
//SORTOUT  DD SYSOUT=*                                               
//SYSIN    DD *                                                     
  SORT FIELDS=COPY                                                   
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(15:+10,ADD,15,2,ZD,EDIT=(TT))),   
  IFTHEN=(WHEN=(15,2,ZD,GE,60),OVERLAY=(12:+1,ADD,12,2,ZD,EDIT=(TT),
  15:15,2,ZD,SUB,+60,EDIT=(TT)),HIT=NEXT),                           
  IFTHEN=(WHEN=(12,2,ZD,GE,24),OVERLAY=(9:+1,ADD,9,2,ZD,EDIT=(TT),   
  12:12,2,ZD,SUB,+24,EDIT=(TT)),HIT=NEXT),                           
  IFTHEN=(WHEN=(09,2,ZD,GT,31),OVERLAY=(6:+1,ADD,6,2,ZD,EDIT=(TT),   
  09:C'01'),HIT=NEXT),                                               
  IFTHEN=(WHEN=(06,2,ZD,GT,12),OVERLAY=(1:+1,ADD,1,4,ZD,EDIT=(TTTT),
  06:C'01'),HIT=NEXT),                                               
  IFTHEN=(WHEN=(06,5,SS,EQ,C'04-31,06-31,09-31,11-31'),             
  OVERLAY=(6:+1,ADD,6,2,ZD,EDIT=(TT),9:C'01'))                       
                                                                     
  OUTREC IFOUTLEN=19,                                               
  IFTHEN=(WHEN=INIT,OVERLAY=(81:1,4,ZD,MOD,+4,EDIT=(T),             
  82:1,4,ZD,MOD,+100,EDIT=(TTT),85:1,4,ZD,MOD,+400,EDIT=(TTT))),     
  IFTHEN=(WHEN=(85,3,ZD,EQ,0,OR,(81,1,ZD,EQ,0,AND,82,3,ZD,GT,0)),   
  OVERLAY=(88:C'L'),HIT=NEXT),                                       
  IFTHEN=(WHEN=(88,1,CH,EQ,C' ',AND,6,5,CH,EQ,C'02-29'),             
  OVERLAY=(6:C'03-01'),HIT=NEXT),                                   
  IFTHEN=(WHEN=(88,1,CH,EQ,C'L',AND,6,5,CH,EQ,C'02-30'),             
  OVERLAY=(6:C'03-01'))                                             
//*
Back to top
View user's profile Send private message
vvmanyam

New User


Joined: 16 Apr 2008
Posts: 86
Location: Bangalore

PostPosted: Thu Nov 12, 2009 8:43 am    Post subject:
Reply with quote

kaushik,

Quote:
if you are using DB2, then you will have to make sure that jobs are executed in DB2 supported environment


You are exactly correct. I can't execute IDMS and DB2 in the same region, so the DB2 is out of option here.

Enrico,
Thanks for the Rexx code.

Ronald,
Thanks for you suggestions.

Skolusu,
Thanks for the sort step.

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

Senior Member


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

PostPosted: Sat Nov 14, 2009 4:09 am    Post subject: Reply to: To add 10 minutes to TIMESTAMP
Reply with quote

vvmanyam,

With z/OS DFSORT V1R5 PTF UK51706 or z/OS DFSORT V1R10 PTF UK51707, you can use the new date conversion functions (TOJUL, TOGREG) like shown below to do the same thing:
Code:

//STEP0100 EXEC PGM=SORT                                             
//SYSOUT   DD SYSOUT=*                                               
//SORTIN   DD *                                                     
2009-11-11-14.10.01                                                 
//SORTOUT  DD SYSOUT=*                                               
//SYSIN    DD *                                                       
  SORT FIELDS=COPY                                                   
  INREC IFOUTLEN=19,                                                 
  IFTHEN=(WHEN=INIT,OVERLAY=(15:+10,ADD,15,2,ZD,EDIT=(TT))),         
  IFTHEN=(WHEN=(15,2,ZD,GE,60),OVERLAY=(12:+1,ADD,12,2,ZD,EDIT=(TT), 
                15:15,2,ZD,SUB,+60,EDIT=(TT)),HIT=NEXT),             
  IFTHEN=(WHEN=(12,2,ZD,EQ,24),OVERLAY=(12:C'00',81:1,10,UFF,M11,     
                LENGTH=8,81,8,Y4T,TOJUL=Y4T,89:+1,ADD,89,7,ZD,M11,   
                LENGTH=7,1:89,7,Y4T,TOGREG=Y4T(-)),HIT=NEXT),         
  IFTHEN=(WHEN=(1,1,CH,EQ,C'*'),OVERLAY=(89:89,4,ZD,ADD,+1,           
          EDIT=(TTTT),93:C'001',1:89,7,Y4T,TOGREG=Y4T(-)))           
//*



For complete details on date conversion functions and the other new functions available with the Nov, 2009 DFSORT PTF, see:

http://www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000174
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 Converting EBCDIC to Unicode (TimeStamp) muralikrishnan_new COBOL Programming 2 Mon Jul 25, 2016 10:42 pm
No new posts Convert Timestamp Value mrdinesh DFSORT/ICETOOL 7 Thu May 05, 2016 6:01 pm
No new posts Comparing timestamp in Synscort l.nethaji SYNCSORT 13 Wed Jan 20, 2016 4:47 pm
No new posts pass numeric value of length 14 to ti... Ralph Zbrog Java & MQSeries 4 Fri Jan 15, 2016 3:20 pm
No new posts Pick a record from a file based on ti... Mani453 COBOL Programming 4 Thu Jan 07, 2016 6:18 am


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