ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » converting from a timestamp to epoch time

Post new topic  Reply to topic
 converting from a timestamp to epoch time « View previous topic :: View next topic » 
Author Message
dean
PostPosted: Wed Aug 12, 2009 10:39 am    Post subject: converting from a timestamp to epoch time Reply with quote

Novice

Joined: 29 May 2009
Posts: 15

This works going from epoch to a timestamp:
SET HrTmStmpSec = TIMESTAMP '1970-01-01 00:00:00' + CAST(InputRoot.MRM.cstdatestamp AS INTERVAL SECOND);

How would I do the reverse -- convert from a timestamp to seconds since 1/1/1970?

Thanks,

Dean
Back to top
View user's profile Send private message
nagarjun_vv
PostPosted: Wed Aug 12, 2009 11:49 pm    Post subject: Reply with quote

Apprentice

Joined: 24 Jun 2008
Posts: 33

to find the difference between two timestamp use this code

(TIMESTAMP '2009-08-13 15:44:00' - TIMESTAMP '1999-08-13 15:44:00') SECOND

Regards,
Nagarjun.
Back to top
View user's profile Send private message Send e-mail
dean
PostPosted: Thu Aug 13, 2009 4:48 am    Post subject: invalid characters error Reply with quote

Novice

Joined: 29 May 2009
Posts: 15

thanks for the reply. I'm getting the following error trying to use your suggestion. Any ideas?

DECLARE HrTmStmpSec INTEGER (TIMESTAMP '2009-06-16 14:18:23' - TIMESTAMP '1970-01-01 00:00:00') SECOND;


(0x01000000:Name ):Insert = (
(0x03000000:NameValue):Type = 5 (INTEGER)
(0x03000000:NameValue):Text = 'DECLARE HrTmStmpSec INTEGER TIMESTAMP '2009-06-16 14:18:23' - TIMESTAMP '1970-01-01 00:00:00';' (CHARACTER)
)
(0x01000000:Name ):ConversionException = (
(0x03000000:NameValue):File = '/build/S610_P/src/CommonServices/ImbUtility.cpp' (CHARACTER)
(0x03000000:NameValue):Line = 436 (INTEGER)
(0x03000000:NameValue):Function = 'imbWcsToInt64' (CHARACTER)
(0x03000000:NameValue):Type = '' (CHARACTER)
(0x03000000:NameValue):Name = '' (CHARACTER)
(0x03000000:NameValue):Label = '' (CHARACTER)
(0x03000000:NameValue):Catalog = 'BIPv610' (CHARACTER)
(0x03000000:NameValue):Severity = 3 (INTEGER)
(0x03000000:NameValue):Number = 2595 (INTEGER)
(0x03000000:NameValue):Text = 'Invalid characters' (CHARACTER)
(0x01000000:Name ):Insert = (
(0x03000000:NameValue):Type = 5 (INTEGER)
(0x03000000:NameValue):Text = 'INTERVAL '1245161903' SECOND' (CHARACTER)
Back to top
View user's profile Send private message
mgk
PostPosted: Thu Aug 13, 2009 7:02 am    Post subject: Reply with quote

Padawan

Joined: 31 Jul 2003
Posts: 1642

You need to CAST the INTERVAL to an INTEGER...
_________________
MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions.
Back to top
View user's profile Send private message
nagarjun_vv
PostPosted: Thu Aug 13, 2009 7:56 pm    Post subject: Reply with quote

Apprentice

Joined: 24 Jun 2008
Posts: 33

Did you check what value you are getting from that.

SET OutputRoot.XML.Hi = (TIMESTAMP '2009-08-13 15:44:00' - TIMESTAMP '1999-08-13 15:44:00') SECOND;

Check the value and do the required changes for that.

Regards,
Nagarjun.
Back to top
View user's profile Send private message Send e-mail
smdavies99
PostPosted: Thu Aug 13, 2009 8:49 pm    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

Don't mess with the XML Domain ulness by some mistake you are using this depreciated parser. If you want to work with XML then use the XMLNSC domain.

As kimbert indicated, you need to CAST the result of your timestamp subtraction to an Integer.

Please look up the CAST ESQL Statememnt in the Documentation.
_________________
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
View user's profile Send private message
dean
PostPosted: Mon Aug 17, 2009 4:30 am    Post subject: solution Reply with quote

Novice

Joined: 29 May 2009
Posts: 15

this worked for me:

DECLARE HrTmStmpSec INTEGER CAST ((datestamp - TIMESTAMP '1970-01-01 00:00:00') SECOND as INTEGER);

thanks to all.

:clap:
Back to top
View user's profile Send private message
kimbert
PostPosted: Mon Aug 17, 2009 4:38 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

smdavies99 said:
Quote:
As kimbert indicated, you need to CAST the result of your timestamp subtraction to an Integer.
Nope. mgk said that. He's right, though.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » converting from a timestamp to epoch time
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.