Page 1 of 1

Regarding Timestamp difference in Cobol

PostPosted: Fri Apr 06, 2012 8:08 pm
by rekhamf
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 ?

Re: Regarding Timestamp difference in Cobol

PostPosted: Fri Apr 06, 2012 8:41 pm
by Robert Sample
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.

Re: Regarding Timestamp difference in Cobol

PostPosted: Fri Apr 06, 2012 8:43 pm
by Akatsukami
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.

Re: Regarding Timestamp difference in Cobol

PostPosted: Fri Apr 06, 2012 10:55 pm
by rekhamf
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 .

Re: Regarding Timestamp difference in Cobol

PostPosted: Sat Apr 07, 2012 12:05 am
by dick scherrer
Hello,

Suggest you post a couple of example date/time pairs and what you want to see as the "difference".

Re: Regarding Timestamp difference in Cobol

PostPosted: Sat Apr 07, 2012 1:27 am
by rekhamf
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.
.

Re: Regarding Timestamp difference in Cobol

PostPosted: Sat Apr 07, 2012 1:48 am
by Akatsukami
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.

Re: Regarding Timestamp difference in Cobol

PostPosted: Tue Apr 10, 2012 1:43 am
by rekhamf
Thank you Akatsukami.I got the solution