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 character to timestamp

Post new topic  Reply to topic
 Converting character to timestamp « View previous topic :: View next topic » 
Author Message
chaitu
PostPosted: Thu Nov 17, 2016 8:27 am    Post subject: Converting character to timestamp Reply with quote

Voyager

Joined: 15 Apr 2014
Posts: 89

Hi All,

I am search for character to time stamp.
Quote:

my source=20161117(character) need to convert it to '1996-05-21T00:00:00'


for this I used below which is working fine
Quote:

ConvertTimeStamp(source);


now if I pass null in source or like source=11172016 it is throwing error like
Quote:

| ConvertTimeStamp | com.src.common.ConvertTimeStamp | 6.4 | SET OutTime = CAST(CAST(inTime AS TIMESTAMP FORMAT 'yyyyMMddHHmmss') AS TIMESTAMP FORMAT 'yyyy-MM-dd HH:mm:ss'); | com.src.common.ConvertTimeStamp | 6.23 | '20163102000000' | TIMESTAMP | -1 | S22007 | 2016 | 31 | 2 TransetID: 2909 AND SubscriberId:


Can anyone help me to figure it out.
Thanks.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Thu Nov 17, 2016 8:47 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Format is used when casting FROM a character TO a Timestamp and FROM a Timestamp TO a Character.

If you have a character that is a timestamp of some sort and you want to convert it to a different formatted character that is also a timestamp, you need to
  1. Cast the character to a timestamp using the right format that represents the input character string
  2. cast the timestamp using the right format to represent the output character string


Casting a timestamp to a timestamp doesn't use a format. Timestamps don't have any format at all.
_________________
chmod -R ugo-wx /
Back to top
View user's profile Send private message
Vitor
PostPosted: Thu Nov 17, 2016 8:48 am    Post subject: Re: Converting character to timestamp Reply with quote

Grand High Poobah

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

chaitu wrote:
Can anyone help me to figure it out.


So what you're asking us to help you figure out is why a FORMAT parameter intended to convert a string in the format yymmdd into a timestamp abends if you feed it mmddyyy or a null?

Most software functions abend if they're given data they don't expect....
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
Vitor
PostPosted: Thu Nov 17, 2016 8:59 am    Post subject: Re: Converting character to timestamp Reply with quote

Grand High Poobah

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

chaitu wrote:
Hi All,

I am search for character to time stamp.
Code:

my source=20161117(character) need to convert it to '1996-05-21T00:00:00'



Do you really want to convert a character string representing 17th November 2016 to a timestamp representing 21st May 1996?

Or is that just a typo?
_________________
Honesty is the best policy.
Insanity is the best defence.
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 character to timestamp
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.