Author |
Message
|
eskil |
Posted: Fri May 08, 2009 1:18 am Post subject: Problems parsing dateTime string with format including AM/PM |
|
|
Novice
Joined: 25 Nov 2008 Posts: 14
|
Hi.
I'm using the XMLNSC domain and wants to parse a dateTime string into a TIMESTAMP. This so I later on can cast it to other formats.
But, I'm having problem with the AM/PM string in the dateTime string.
Here's an example of the string: '1/19/2008 8:32:45 AM'
This is how my code looks like:
Code: |
DECLARE TransferDateString CHARACTER;
DECLARE TransferDate TIMESTAMP;
DECLARE DateString CHARACTER;
DECLARE TimeString CHARACTER;
SET TransferDateString = '1/19/2008 8:32:45 AM';
SET TransferDate = CAST(TransferDateString AS TIMESTAMP FORMAT 'M/dd/yyyy h:mm:ss a');
SET DateString = CAST(CAST(TransferDate AS DATE FORMAT 'yyyyMMdd') AS CHARACTER);
SET TimeString = CAST(CAST(TransferDate AS TIME FORMAT 'HH:mm:ss') AS CHARACTER);
|
When running the code I get an exception: "No am / pm here" |
|
Back to top |
|
 |
fjb_saper |
Posted: Fri May 08, 2009 2:40 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Why do you need a format when you cast a timestamp to a date?
Why do you need a format when you cast a timestamp to a time?
Check how your parentheses are set...
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
eskil |
Posted: Fri May 08, 2009 2:58 am Post subject: |
|
|
Novice
Joined: 25 Nov 2008 Posts: 14
|
Yes you are correct, you don't need to cast it twice. *changing the code*
Still the problem is in the first cast. |
|
Back to top |
|
 |
fjb_saper |
Posted: Fri May 08, 2009 3:02 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
eskil wrote: |
Yes you are correct, you don't need to cast it twice. *changing the code*
Still the problem is in the first cast. |
Verify your format string using the manual.  _________________ MQ & Broker admin |
|
Back to top |
|
 |
eskil |
Posted: Fri May 08, 2009 3:18 am Post subject: |
|
|
Novice
Joined: 25 Nov 2008 Posts: 14
|
Done it trice already.. Everything works if I remove 'a' from the format string and AM/PM from the dateTime string. |
|
Back to top |
|
 |
|