Author |
Message
|
Kjelle13 |
Posted: Wed Oct 16, 2013 12:38 am Post subject: How to Calculate a time from another time? |
|
|
Newbie
Joined: 16 Oct 2013 Posts: 4
|
HI
In a Compute node I have the need to define a Timestamp which is GMT minus one hour. Anyone having an idea of how to do this without a lot of ESQL coding? |
|
Back to top |
|
 |
smdavies99 |
Posted: Wed Oct 16, 2013 12:42 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
- INTERVAL '1' HOUR _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
dogorsy |
Posted: Wed Oct 16, 2013 2:53 am Post subject: Re: How to Calculate a time from another time? |
|
|
Knight
Joined: 13 Mar 2013 Posts: 553 Location: Home Office
|
Kjelle13 wrote: |
HI
In a Compute node I have the need to define a Timestamp which is GMT minus one hour. Anyone having an idea of how to do this without a lot of ESQL coding? |
if you look at the documentation you will find that you do not need a lot of ESQL coding. |
|
Back to top |
|
 |
Kjelle13 |
Posted: Wed Oct 16, 2013 3:11 am Post subject: |
|
|
Newbie
Joined: 16 Oct 2013 Posts: 4
|
Thanks, however it seems like the GMTTIMESTAMP Datatype does not work for me.
Like this:
DECLARE MyGMTTimeStamp GMTTIMESTAMP CURRENT_GMTTIMESTAMP;
DECLARE TIME_RECEIVER CHARACTER SUBSTRING(CAST(MyGMTTimeStamp AS CHARACTER) FROM 12 FOR 19);
This one gives Blank Values, since when I debug it the CURRENT_GMTTIMESTAMP gives blank values.
Do I need to configure something in the Broker set or what else dop I do wrong? |
|
Back to top |
|
 |
lancelotlinc |
Posted: Wed Oct 16, 2013 3:14 am Post subject: |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
Kjelle13 wrote: |
Thanks, however it seems like the GMTTIMESTAMP Datatype does not work for me.
Like this:
DECLARE MyGMTTimeStamp GMTTIMESTAMP CURRENT_GMTTIMESTAMP;
DECLARE TIME_RECEIVER CHARACTER SUBSTRING(CAST(MyGMTTimeStamp AS CHARACTER) FROM 12 FOR 19);
This one gives Blank Values, since when I debug it the CURRENT_GMTTIMESTAMP gives blank values.
Do I need to configure something in the Broker set or what else dop I do wrong? |
No. You need to READ THE DOCUMENTATION ! _________________ http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER |
|
Back to top |
|
 |
Kjelle13 |
Posted: Wed Oct 16, 2013 3:31 am Post subject: |
|
|
Newbie
Joined: 16 Oct 2013 Posts: 4
|
|
Back to top |
|
 |
lancelotlinc |
Posted: Wed Oct 16, 2013 3:37 am Post subject: |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
Do it again. Your head is thick.
Code: |
Compute1 : SET Environment.Variables.XMLNSC.{ReplyId}.StartTime = CURRENT_GMTTIMESTAMP;
...
Compute2 : SET Environment.Variables.XMLNSC.{ReplyId}.EndTime = CURRENT_GMTTIMESTAMP;
SET Environment.Variables.XMLNSC.{ReplyId}.ElapsedTime = ( CAST ( Environment.Variables.XMLNSC.{ReplyId}.EndTime AS TIME ) - CAST ( Environment.Variables.XMLNSC.{ReplyId}.StartTime AS TIME )) SECOND;
...
Result found in Trace output :
(0x03000000:NameValue):StartTime = GMTTIMESTAMP '2013-10-16 11:21:11.380991' (GMTTIMESTAMP)
(0x03000000:NameValue):EndTime = GMTTIMESTAMP '2013-10-16 11:23:49.963753' (GMTTIMESTAMP)
(0x03000000:NameValue):ElapsedTime = INTERVAL '158.582762' SECOND (INTERVAL) |
_________________ http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER |
|
Back to top |
|
 |
mqjeff |
Posted: Wed Oct 16, 2013 3:38 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
And never use substring when a FORMAT clause is available. |
|
Back to top |
|
 |
smdavies99 |
Posted: Wed Oct 16, 2013 3:46 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
lancelotlinc wrote: |
Do it again. Your head is thick.
|
so in all your time using broker you have never had any problems/difficulties with date time manipulations then?
Please don't insult people like that. It is no wonder that people have said to me that this is not a very friendly forum and for that reason they don't post or visit here.
Lighten up a little.  _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
lancelotlinc |
Posted: Wed Oct 16, 2013 4:17 am Post subject: |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
smdavies99 wrote: |
lancelotlinc wrote: |
Do it again. Your head is thick.
|
so in all your time using broker you have never had any problems/difficulties with date time manipulations then?
Please don't insult people like that. It is no wonder that people have said to me that this is not a very friendly forum and for that reason they don't post or visit here.
Lighten up a little.  |
I dunno davies. There are 138 different posts on mqseries.net for manipulating GMTTIMESTAMP.
Between using Google to search mqseries.net , reading the InfoCentre that talks explictly about how to subtract two time values, or attending the training class, a reasonable person would be able to piece together the required knowledge.
When they cannot, not because the documentation is not there, but because they do not pursue it diligently (because they may be lazy), then some prick might be needed to jump-start their view of self-motivation. _________________ http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER |
|
Back to top |
|
 |
mqjeff |
Posted: Wed Oct 16, 2013 4:27 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
It's a more complicated problem than it seems.
If in general, the forum appears 'unfriendly', then people complain.
If, in general, the forum appears 'friendly and welcoming', then thousands and thousands of people show up and start asking for everyone else to do their own work.
And then people complain.
If someone posts a basic question that is directly addressed by easy to find documentation, and nobody responds because it's obviously a waste of time, then people complain.
The important thing to aim for, I believe, is 'professional'. Not 'friendly and welcoming', not 'hostile and offputting'.
This is a professional forum, for professionals. If you've done your homework, and you are confused, or stuck, you should be able to get answers without getting jumped on.
If an answer has been given, it's better to leave the question be, rather than add to the confusion. And there's simply no reason to be directly insulting.
I do not claim to be a sterling example of the values I have espoused above. I suggest that I do at least *try* to live them. |
|
Back to top |
|
 |
Kjelle13 |
Posted: Wed Oct 16, 2013 4:47 am Post subject: |
|
|
Newbie
Joined: 16 Oct 2013 Posts: 4
|
OK, so it's an RTFM problem. May be so. However if you do your homework and still do not get it work I think it is relevant to see if any of you have hit this problem before.
The way I try to behave is: if I find a post ridicoluos (which I do sometimes) I do not bother.
I indeed agree that there may be a problem with people posting trivial coding problems, the way I would react then would be either of:
* Do not bother to answer at all
* Answer somthing in the style of ' There are some posts on this, search on ..... Hope it helps you'
This, to me , is to be professional. |
|
Back to top |
|
 |
smdavies99 |
Posted: Wed Oct 16, 2013 5:04 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
Code: |
declare tMyTimestamp TIMESTAMP CURRENT_GMTTIMESTAMP;
set tMyTimestamp = tMyTimestamp - INTERVAL '1' HOUR;
|
That should give you a timestamp (in timestamp form). You can convert it to a CHARACTER using a cast with a format clause. _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
Vitor |
Posted: Wed Oct 16, 2013 5:20 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
lancelotlinc wrote: |
smdavies99 wrote: |
lancelotlinc wrote: |
Do it again. Your head is thick.
|
so in all your time using broker you have never had any problems/difficulties with date time manipulations then?
Please don't insult people like that. It is no wonder that people have said to me that this is not a very friendly forum and for that reason they don't post or visit here.
Lighten up a little.  |
I dunno davies. There are 138 different posts on mqseries.net for manipulating GMTTIMESTAMP.
Between using Google to search mqseries.net , reading the InfoCentre that talks explictly about how to subtract two time values, or attending the training class, a reasonable person would be able to piece together the required knowledge.
When they cannot, not because the documentation is not there, but because they do not pursue it diligently (because they may be lazy), then some prick might be needed to jump-start their view of self-motivation. |
Describing someone as "thick headed" is not professional. Using a sexual adjective to describe anyone is not professional and could be considered abusive.
This is crossing the line from even your usual style of annoying insults. Move back across the line or face sanctions. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed Oct 16, 2013 10:49 am Post subject: Re: How to Calculate a time from another time? |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Kjelle13 wrote: |
HI
In a Compute node I have the need to define a Timestamp which is GMT minus one hour. Anyone having an idea of how to do this without a lot of ESQL coding? |
Ok so here we are talking about a local timestamp...
However if it is for the purpose of working with dates and times you are on the wrong path. Doesn't matter if the local time is GMT -1 or whatever as long as it is always expressed in GMT you are fine.
Now as a display timestamp the broker will support the current local timestamp.... (might be one hour off (DST) if the timestamp is not current.
My advice: timestamps (and gmttimestamps) should always be handled with a format to cast from timestamp to string and vice versa. Use Java to convert from one timezone into another (especially if not part of the broker's local TZ), but keep it all in GMT at the broker level.
And again there is no such thing as GMT -x or +x when calculating it all in GMT.
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
|