Author |
Message
|
lokeshraghuram |
Posted: Fri Feb 07, 2014 10:06 pm Post subject: Conversion of date format |
|
|
Novice
Joined: 10 Dec 2013 Posts: 14
|
Hello Everyone
Can anyone help me to convert dd/mm/yyyy format to YYYYMMDD using single esql statement?? |
|
Back to top |
|
 |
smdavies99 |
Posted: Fri Feb 07, 2014 10:11 pm Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
Why do you need to do it in a single statement?
How do you think it can be done NOT in a single 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 |
|
 |
lokeshraghuram |
Posted: Fri Feb 07, 2014 10:25 pm Post subject: |
|
|
Novice
Joined: 10 Dec 2013 Posts: 14
|
I am extracting DD,MM,YYYY using substring and concatenating to get the required format. This is quite complex..Is there an easy way to do this? |
|
Back to top |
|
 |
dogorsy |
Posted: Fri Feb 07, 2014 10:32 pm Post subject: |
|
|
Knight
Joined: 13 Mar 2013 Posts: 553 Location: Home Office
|
lokeshraghuram wrote: |
I am extracting DD,MM,YYYY using substring and concatenating to get the required format. This is quite complex..Is there an easy way to do this? |
Similar questions have been asked several times in this forum. You only need to search it, or look at the available functions in the infocentre. |
|
Back to top |
|
 |
Gralgrathor |
Posted: Mon Feb 10, 2014 2:27 am Post subject: Re: Conversion of date format |
|
|
Master
Joined: 23 Jul 2009 Posts: 297
|
lokeshraghuram wrote: |
Can anyone help me to convert dd/mm/yyyy format to YYYYMMDD using single esql statement?? |
In two statements:
Code: |
-- DECLARE inputDate CHARACTER; -- contains date in format dd/mm/yyyy
DECLARE toTimestamp TIMESTAMP CAST(inputDate as TIMESTAMP FORMAT 'dd/MM/yyyy');
DECLARE toString CHARACTER CAST(toTimestamp as CHARACTER FORMAT 'yyyyMMdd'); |
Integrate, and you get
Code: |
DECLARE toString CHARACTER CAST(CAST(inputDate as TIMESTAMP FORMAT 'dd/MM/yyyy') as CHARACTER FORMAT 'yyyyMMdd'); |
But really, all of this is documented at the info pages for the CAST function. |
|
Back to top |
|
 |
|