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 format

Post new topic  Reply to topic
 Timestamp format « View previous topic :: View next topic » 
Author Message
Bichu
PostPosted: Fri Sep 16, 2016 8:38 am    Post subject: Timestamp format Reply with quote

Centurion

Joined: 16 Oct 2011
Posts: 124
Location: London

Hallo Guys,

I know you might read through similar kind of stuffs over here so many times because I have also read through but couldn't find a solution to my problem.

I am just trying to get the current time and i would like it to be in the format HH:mm:ss.

DECLARE castTime TIME;
SET castTime = CAST (CURRENT_GMTTIME AS TIME FORMAT 'HH:mm:ss');

But the output is always similar to HH:mm:ss.sss(eg: 17:07:20.149)

I have read through the below link in detail and implemented as such but still no luck
http://www.ibm.com/support/knowledgecenter/SSKM8N_8.0.0/com.ibm.etools.mft.doc/ak05616_.htm

Could you guys point out where am I going wrong.

I am working on IIB V9.0.0
Back to top
View user's profile Send private message
mqjeff
PostPosted: Fri Sep 16, 2016 8:42 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Format only applies when casting to a date/time/datetime from a string or casting from a data/time/datetime to a string.

date/time/datetimes don't have any "format", they're a primitive type.
_________________
chmod -R ugo-wx /
Back to top
View user's profile Send private message
Vitor
PostPosted: Fri Sep 16, 2016 8:47 am    Post subject: Re: Timestamp format Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

Bichu wrote:
Could you guys point out where am I going wrong.


You're casting to a TIME datatype, which has the format you're seeing when implicitly cast to a character datatype.

If you're trying to output the timestamp as a character string with a format "HH:mm:ss" then you should probably do that.

If you're trying to do something else, you problem need to explain it further
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
Vitor
PostPosted: Fri Sep 16, 2016 8:51 am    Post subject: Re: Timestamp format Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

Bichu wrote:
I am working on IIB V9.0.0


Pedantically, you're not. IIB has 4 levels to it's version - 9.0.0.n

This is important because the last level is the fix pack level you're using. Calling it 9.0.0 doesn't say what maintenance you've got applied and renders us unable to determine if the problem is within the software (and there's a known fix), in your code or between your ears.

This specific problem appears to be the latter.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
rekarm01
PostPosted: Fri Sep 16, 2016 9:46 am    Post subject: Re: Timestamp format Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 1415

Bichu wrote:
Code:
SET castTime = CAST (CURRENT_GMTTIME AS TIME ...);

There is also the CURRENT_TIME function, which doesn't need casting from GMTTIME to local TIME.
Back to top
View user's profile Send private message
Bichu
PostPosted: Mon Sep 19, 2016 1:00 am    Post subject: Re: Timestamp format Reply with quote

Centurion

Joined: 16 Oct 2011
Posts: 124
Location: London

Vitor wrote:


If you're trying to output the timestamp as a character string with a format "HH:mm:ss" then you should probably do that.


This is what I need vitor. But I need the current time. Hence I am getting the current time and trying to cast it to a string.
Back to top
View user's profile Send private message
smdavies99
PostPosted: Mon Sep 19, 2016 1:14 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.

In your original post we see this
Code:

DECLARE castTime TIME;
SET castTime = CAST (CURRENT_GMTTIME AS TIME FORMAT 'HH:mm:ss');


Now you say that you want the Current time cast as a char.

A previous answer indicated that the CAST with format applies to a CHAR.

Combine the two and what do you get?

{hint, change the datatype of 'castTime'}
_________________
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
Vitor
PostPosted: Mon Sep 19, 2016 5:06 am    Post subject: Re: Timestamp format Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

Bichu wrote:
trying to cast it to a string.


No you're not.

Bichu wrote:
Code:
CAST (CURRENT_GMTTIME AS TIME


If you read that in English (as you're clearly unable to read the description of the command in the InfoCenter) then it says:

"Cast the current GMT time as a time"

What part of that sounds like:

"Cast the current GMT time as a string"

How can you even think that would do what you want?

_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Mon Sep 19, 2016 5:26 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

No kind of date or time variable in IIB will have any format at all.

As said, Format is used to cast FROM a character to a date, or FROM a date to a character.
_________________
chmod -R ugo-wx /
Back to top
View user's profile Send private message
Bichu
PostPosted: Mon Sep 19, 2016 6:09 am    Post subject: Reply with quote

Centurion

Joined: 16 Oct 2011
Posts: 124
Location: London

Thanks all. I have got the output now.

DECLARE castTime CHARACTER;
SET castTime = CAST (CURRENT_TIME AS CHARACTER FORMAT 'HH:mm:ss');
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 format
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.