Author |
Message
|
vincentDE |
Posted: Fri May 24, 2013 3:03 am Post subject: Get TIMESTAMP Difference |
|
|
Newbie
Joined: 24 May 2013 Posts: 1
|
Hello,
Im using the following code:
Code: |
CREATE COMPUTE MODULE ProcessStateInfo
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
-- CALL CopyMessageHeaders();
-- CALL CopyEntireMessage();
DECLARE currentTimestamp TIMESTAMP CURRENT_TIMESTAMP;
DECLARE oldtime TIMESTAMP;
DECLARE diff INTERVAL;
SET oldtime = CAST('2013-05-21 09:15:30.291' AS TIMESTAMP);
SET diff = (currentTimestamp - oldtime) DAY TO HOUR;
RETURN TRUE;
END; |
My Problem is that "diff" has no value. One other forum user here had a same problem years ago.
viewtopic.php?t=51172&sid=68eaac55e03f9f48d617677b04224779
I did not find any solution. Can you help me?
Best Regards,
Vincent |
|
Back to top |
|
 |
mqjeff |
Posted: Fri May 24, 2013 4:28 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
You need to specify a FORMAT for the CAST. |
|
Back to top |
|
 |
lancelotlinc |
Posted: Fri May 24, 2013 4:33 am Post subject: |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
Trivia: TIMESTAMP values collected in the same Compute node will have the same value. When you want to measure the time it takes ESQL to accomplish a particular task, you need two Compute nodes, the first to get the current time and accomplish the work, the second to get the current time after the work was accomplished and to calculate the difference between start and finish. _________________ http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER |
|
Back to top |
|
 |
mqjeff |
Posted: Fri May 24, 2013 4:38 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
lancelotlinc wrote: |
Trivia: TIMESTAMP values collected in the same Compute node will have the same value. When you want to measure the time it takes ESQL to accomplish a particular task, you need two Compute nodes, the first to get the current time and accomplish the work, the second to get the current time after the work was accomplished and to calculate the difference between start and finish. |
I'm not sure that's accurate. Perhaps it's changed in v8, but it used to be that calling CURRENT_TIMESTAMP returned the same value at all places within the same message flow instance. |
|
Back to top |
|
 |
lancelotlinc |
Posted: Fri May 24, 2013 4:56 am Post subject: |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
mqjeff wrote: |
lancelotlinc wrote: |
Trivia: TIMESTAMP values collected in the same Compute node will have the same value. When you want to measure the time it takes ESQL to accomplish a particular task, you need two Compute nodes, the first to get the current time and accomplish the work, the second to get the current time after the work was accomplished and to calculate the difference between start and finish. |
I'm not sure that's accurate. Perhaps it's changed in v8, but it used to be that calling CURRENT_TIMESTAMP returned the same value at all places within the same message flow instance. |
I know for V7 and V8, the current time is scoped to Compute node only. Two Compute nodes in the same message flow will return two different time values. You may be correct for V6. _________________ http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER |
|
Back to top |
|
 |
Vitor |
Posted: Fri May 24, 2013 5:00 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
lancelotlinc wrote: |
I know for V7 and V8, the current time is scoped to Compute node only. Two Compute nodes in the same message flow will return two different time values. You may be correct for V6. |
For the record and the benefit of future readers, see here
Quote: |
All calls to CURRENT_TIMESTAMP within the processing of one node are guaranteed to return the same value |
_________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
dogorsy |
Posted: Fri May 24, 2013 8:32 am Post subject: |
|
|
Knight
Joined: 13 Mar 2013 Posts: 553 Location: Home Office
|
lancelotlinc wrote: |
mqjeff wrote: |
lancelotlinc wrote: |
Trivia: TIMESTAMP values collected in the same Compute node will have the same value. When you want to measure the time it takes ESQL to accomplish a particular task, you need two Compute nodes, the first to get the current time and accomplish the work, the second to get the current time after the work was accomplished and to calculate the difference between start and finish. |
I'm not sure that's accurate. Perhaps it's changed in v8, but it used to be that calling CURRENT_TIMESTAMP returned the same value at all places within the same message flow instance. |
I know for V7 and V8, the current time is scoped to Compute node only. Two Compute nodes in the same message flow will return two different time values. You may be correct for V6. |
it is better to invoke from the same compute node a simple java pgm that returns the time and then calculate the difference. |
|
Back to top |
|
 |
lancelotlinc |
Posted: Fri May 24, 2013 9:14 am Post subject: |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
dogorsy wrote: |
lancelotlinc wrote: |
mqjeff wrote: |
lancelotlinc wrote: |
Trivia: TIMESTAMP values collected in the same Compute node will have the same value. When you want to measure the time it takes ESQL to accomplish a particular task, you need two Compute nodes, the first to get the current time and accomplish the work, the second to get the current time after the work was accomplished and to calculate the difference between start and finish. |
I'm not sure that's accurate. Perhaps it's changed in v8, but it used to be that calling CURRENT_TIMESTAMP returned the same value at all places within the same message flow instance. |
I know for V7 and V8, the current time is scoped to Compute node only. Two Compute nodes in the same message flow will return two different time values. You may be correct for V6. |
it is better to invoke from the same compute node a simple java pgm that returns the time and then calculate the difference. |
Not !!
http://www.mqseries.net/phpBB2/viewtopic.php?p=348393&sid=af7624474dc93ebd82d65d4c5d7b062f _________________ http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER |
|
Back to top |
|
 |
|