By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,227 Members | 1,026 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,227 IT Pros & Developers. It's quick & easy.

Converting from char to date/time

P: n/a

I have a char column that contains date/time information
(YYYYMMDDTTTTTT) in the following format: 20071002160603

What is the most efficient way to show this information in a query
result as "10/02/2007 16:06:03"?

Thanks in advance.

Nov 5 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"pali" <pa**********@gmail.comwrote in message
news:11*********************@e34g2000pro.googlegro ups.com...
>
I have a char column that contains date/time information
(YYYYMMDDTTTTTT) in the following format: 20071002160603

What is the most efficient way to show this information in a query
result as "10/02/2007 16:06:03"?

Thanks in advance.
SUBSTR(COL1, 5,2)||'/'||SUBSTR(COL1, 7,2)||'/'||SUBSTR(COL1, 1,4)||'
'||SUBSTR(COL1, 9,2)||:||.....

I will let you finish the rest of it.
Nov 5 '07 #2

P: n/a
pali wrote:
I have a char column that contains date/time information
(YYYYMMDDTTTTTT) in the following format: 20071002160603

What is the most efficient way to show this information in a query
result as "10/02/2007 16:06:03"?
In DB2 9.5 you can use TO_CHAR/TO_DATE
or in general you can just use SUBSTR and CONCAT. Not clear which one is
faster

Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Nov 5 '07 #3

P: n/a
Although, I don't know if this is more efficient than using SUBSTR and
CONCAT.
One simple example is as following.
TRANSLATE('ef/gh/abcd ij:kl:mn',your_column,'abcdefghijklmn')

Nov 8 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.