|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Current Timestamp esql is producing an &apos - Failing |
« View previous topic :: View next topic » |
Author |
Message
|
rharikumar |
Posted: Mon Oct 14, 2013 5:21 am Post subject: Current Timestamp esql is producing an &apos - Failing |
|
|
Novice
Joined: 14 Oct 2013 Posts: 16
|
Hi
I am using current timestamp for a variable . But in certain scenarios , i am getting a value as below , which is failing in the target system .
2013-10-08T10:48:11.374'
Does anyone have any idea about such a scenario with timestamp ??
Code Snippet :
SUBSTRING(REPLACE(REPLACE(CAST(CURRENT_GMTTIMESTAMP AS CHARACTER),' ','T'),'GMTTIMESTAMPT','')FROM 2 FOR 26); |
|
Back to top |
|
 |
lancelotlinc |
Posted: Mon Oct 14, 2013 5:28 am Post subject: |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
Your code fails to make use of the FORMAT clause. The InfoCentre has explicit examples about how to format time and date strings. Have you read those ? _________________ http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER |
|
Back to top |
|
 |
McueMart |
Posted: Mon Oct 14, 2013 6:17 am Post subject: |
|
|
 Chevalier
Joined: 29 Nov 2011 Posts: 490 Location: UK...somewhere
|
The root cause is because normally CURRENT_TIMESTAMP will return in the format: 2006-02-01 13:13:56.444730 , but if the trailing microseconds are all 0's e.g. 2006-02-01 13:13:56.444000, it will actually return as 2006-02-01 13:13:56.444. This means that when you do your SUBSTRING, you are getting one of the apostrophes.
As lancelotlinc pointed out, you might want to look at the format options to avoid this issue and the horrible code you currently have in place. |
|
Back to top |
|
 |
smdavies99 |
Posted: Mon Oct 14, 2013 6:25 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
McueMart wrote: |
As lancelotlinc pointed out, you might want to look at the format options to avoid this issue and the horrible code you currently have in place. |
 _________________ 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 |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|