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 » timestamp formatting

Post new topic  Reply to topic
 timestamp formatting « View previous topic :: View next topic » 
Author Message
Skumarmly
PostPosted: Mon Jun 15, 2015 5:35 am    Post subject: timestamp formatting Reply with quote

Novice

Joined: 09 Sep 2014
Posts: 13

In response I could see date field with value Mon, 15 Jun 2015 13:32:17 GMT(character) I need that in Timestamp format yyyy-mm-dd hh:mm:ss

I used cast function but its throwing error

suggest me the code its v urgent
Back to top
View user's profile Send private message
smdavies99
PostPosted: Mon Jun 15, 2015 5:44 am    Post subject: Reply with quote

Jedi Council

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

What is the code that you are using for the cast?
_________________
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
mqjeff
PostPosted: Mon Jun 15, 2015 5:49 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

You don't need it in any format until you put it in an output field that does not contain a date or time or datetime type.

What happens if you simply don't try to cast it?
Back to top
View user's profile Send private message
Skumarmly
PostPosted: Mon Jun 15, 2015 7:26 am    Post subject: Reply with quote

Novice

Joined: 09 Sep 2014
Posts: 13

DECLARE respTime CHARACTER InputRoot.HTTPResponseHeader.Date;
DECLARE RespTime TIMESTAMP CAST(respTime AS TIMESTAMP FORMAT 'EEE,DD-MMM-YYYY HH:MM:SS');
Back to top
View user's profile Send private message
Skumarmly
PostPosted: Mon Jun 15, 2015 7:30 am    Post subject: Reply with quote

Novice

Joined: 09 Sep 2014
Posts: 13

I'm planning to add some Minutes to that time stamp to perform transactions till that time ends.

once the current time Reaches that time transactions should stop or again request for a new expiry time
Back to top
View user's profile Send private message
mqjeff
PostPosted: Mon Jun 15, 2015 7:31 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

You can't cast a timestamp to a timestamp.

You can't specify that a timestamp has a specific format. It's a timestamp.

If you want to add minutes, you simply add minutes.
Back to top
View user's profile Send private message
Skumarmly
PostPosted: Mon Jun 15, 2015 7:36 am    Post subject: Reply with quote

Novice

Joined: 09 Sep 2014
Posts: 13

under InputRoot.HTTPResponseHeader.Date I have " Mon, 15 Jun 2015 13:32:17 GMT "

so you mean to say I cant cast this character to timestamp???
Back to top
View user's profile Send private message
mqjeff
PostPosted: Mon Jun 15, 2015 7:44 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

You can cast a character to a timestamp.

The format in this case is the format of the data in the character.

So you use the format to tell the case how to understand the string.

Once it's a timestamp, you don't need to cast it again until you're done with it. Then the format tells the cast how to output the timestamp.
Back to top
View user's profile Send private message
smdavies99
PostPosted: Mon Jun 15, 2015 7:44 am    Post subject: Reply with quote

Jedi Council

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

If you put a Trace node before your Compute Node and set the output pattern to

${Root}

You will see that the InputRoot.HTTPResponseHeader.Date is shown as Mon, 15 Jun 2015 13:32:17 GMT
but the data type is TIMESTAMP. You can't cast a TIMESTAMP to a TIMESTAMP.

You can cast the TIMESTAMP to a CHAR that will give you the formatted output you desire with proper use of the FORMAT paramter of the CAST statement.
_________________
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
Skumarmly
PostPosted: Mon Jun 15, 2015 10:05 am    Post subject: Reply with quote

Novice

Joined: 09 Sep 2014
Posts: 13

DECLARE respTime CHARACTER CAST(InputRoot.HTTPResponseHeader.Date AS CHARACTER FORMAT 'yyyy-MM-dd HH:mm:ss');


but its not formatting
respTime:CHARACTER:Mon, 15 Jun 2015 18:04:04 GMT

am getting as it is
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Mon Jun 15, 2015 10:26 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

Skumarmly wrote:
DECLARE respTime CHARACTER CAST(InputRoot.HTTPResponseHeader.Date AS CHARACTER FORMAT 'yyyy-MM-dd HH:mm:ss');


but its not formatting
respTime:CHARACTER:Mon, 15 Jun 2015 18:04:04 GMT

am getting as it is

Could that be because even though InputRoot.HTTPResponseHeader.Date CONTAINS a date information, the TYPE of the field seems to be CHARACTER....
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
wbisantosh
PostPosted: Mon Jun 15, 2015 10:38 am    Post subject: Reply with quote

Apprentice

Joined: 12 Nov 2012
Posts: 47

Try this,



Code:
   DECLARE outTS CHAR;
   DECLARE inTS TIMESTAMP;
   SET inTS = CAST(InputRoot.HTTPResponseHeader.Date AS TIMESTAMP FORMAT 'EEE, dd MMM YYYY HH:mm:ss zz');
   SET outTS = CAST(inTS AS CHARACTER FORMAT 'yyyy-MM-dd HH:mm:ss');


The Input is the TIMESTAMP and Output will be CHAR

Santosh
Back to top
View user's profile Send private message
Skumarmly
PostPosted: Mon Jun 15, 2015 11:36 pm    Post subject: Reply with quote

Novice

Joined: 09 Sep 2014
Posts: 13

Thanks Santosh ,this code served my purpose and thanks everyone
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 » timestamp formatting
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.