Regarding Timestamp difference in Cobol



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Regarding Timestamp difference in Cobol

Postby rekhamf » Fri Apr 06, 2012 8:08 pm

Hi ,

I need to get the time stamp difference before and after MQPUT and MQGET in COBOL.

So i get the timestamp from DB2 and stored in Field1 which is x(26)
after MQPUT

I get the timestamp from Db2 and stored in field2 which is x(26)

I need to get the differnce between Field3 - Field 2- Field1
How i can do this,since Timestamp declartion is X(26) , How can I calcuate the difference ?
And also I need to show this difference in the report too. Can someone help me in this regard ?
rekhamf
 
Posts: 33
Joined: Mon Nov 28, 2011 5:09 am
Has thanked: 0 time
Been thanked: 0 time

Re: Regarding Timestamp difference in Cobol

Postby Robert Sample » Fri Apr 06, 2012 8:41 pm

Do you know what the layout is for the timestamp field? If not, that is your first task -- is it a 26-digit number that represents the number of ? since ? or is it a formatted field (such as YYYY/MM/DD HH:MM:SS:TH AM/PM)? The logic you would use will vary depending upon the format of the data.
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: Regarding Timestamp difference in Cobol

Postby Akatsukami » Fri Apr 06, 2012 8:43 pm

rekhamf wrote:Hi ,

I need to get the time stamp difference before and after MQPUT and MQGET in COBOL.

So i get the timestamp from DB2 and stored in Field1 which is x(26)
after MQPUT

I get the timestamp from Db2 and stored in field2 which is x(26)

I need to get the differnce between Field3 - Field 2- Field1
How i can do this,since Timestamp declartion is X(26) , How can I calcuate the difference ?
And also I need to show this difference in the report too. Can someone help me in this regard ?

Begin by reading the fine manual in re CEEDAYS. Study the COBOL example (Figure 89) and then ask questions about what you do not comprehend.
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1058
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: Regarding Timestamp difference in Cobol

Postby rekhamf » Fri Apr 06, 2012 10:55 pm

Hi ,

I will get the value in below format :

2012-04-06-13.23.04.310037 - this value will be move to X(26) field .
rekhamf
 
Posts: 33
Joined: Mon Nov 28, 2011 5:09 am
Has thanked: 0 time
Been thanked: 0 time

Re: Regarding Timestamp difference in Cobol

Postby dick scherrer » Sat Apr 07, 2012 12:05 am

Hello,

Suggest you post a couple of example date/time pairs and what you want to see as the "difference".
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: Regarding Timestamp difference in Cobol

Postby rekhamf » Sat Apr 07, 2012 1:27 am

Ex :

TIMESTAMP2('2012-04-06-02.53.53.434868') -TIMESTAMP('2012-04-06-01.52.52.434868') will have 10101.000000 (1 hr,01 min,01 sec)
but how i can use this once again for calcuating difference. I will get difference mostly in seconds . not more than that.
.
rekhamf
 
Posts: 33
Joined: Mon Nov 28, 2011 5:09 am
Has thanked: 0 time
Been thanked: 0 time

Re: Regarding Timestamp difference in Cobol

Postby Akatsukami » Sat Apr 07, 2012 1:48 am

rekhamf wrote:Ex :

TIMESTAMP2('2012-04-06-02.53.53.434868') -TIMESTAMP('2012-04-06-01.52.52.434868') will have 10101.000000 (1 hr,01 min,01 sec)
but how i can use this once again for calcuating difference. I will get difference mostly in seconds . not more than that.
.

Use CEESECS to convert your timestamps (less the fractions) into an integral number of Lilian seconds. Add the fractions back. Subtract one from the other.
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1058
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: Regarding Timestamp difference in Cobol

Postby rekhamf » Tue Apr 10, 2012 1:43 am

Thank you Akatsukami.I got the solution
rekhamf
 
Posts: 33
Joined: Mon Nov 28, 2011 5:09 am
Has thanked: 0 time
Been thanked: 0 time


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post