473,320 Members | 1,848 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Converting from char to date/time


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
3 7769
"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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: ola Alli | last post by:
Hi All, How do you convert int value to datetime datatype in sql server e.g 900mins to hh:mm:ss Regards Ola
1
by: Sugapablo | last post by:
I have a table that's of type date/time (i.e. 01/01/1900 00:00:00). What I want is to do the following: Say you have these records: person | date-time -------+---------------------------...
3
by: Alpha | last post by:
I have 2 strings, "12/28/2005" and "16:44:54". I need to conatenate them and convert them to datetime format so I can assign them to a datetime field in a datarow. The time is now being converted...
12
by: Rob Meade | last post by:
Hi all, Ok - I've come from a 1.1 background - and previously I've never had any problem with doing this: Response.Write (Session("MyDate").ToString("dd/MM/yyyy")) So, I might get this for...
2
by: savigliano | last post by:
hello, i am doing a date comparation and i have reallize that the data i have in my database (general date format) it is causing me problems, and because i don´t need the time data i would like to...
0
by: coolvivek33 | last post by:
hi i am facing a strange problem i am trying to build report using sql server 2005 and microsoft visual studio2005 now it is in requirement that i should seperate date from time.I have done that...
3
by: Jef Driesen | last post by:
How can I convert a date string to a number (e.g. a time_t value or a tm struct)? I know about the strptime function, but then I have to know the format string. And that is a problem. I'm trying...
5
by: Hemant Shah | last post by:
Folks, How can I convert date/time/timestamp to an integer? According to UDB 8.1 docs that I have, INTEGER('1964-07-20') should return 19640720, but when I run the SQL statement I get...
1
by: rob41 | last post by:
I'm in the process of converting numerous queries from access 07 to sql server 05 to improve runtime performance. Below is a sample of code and the error I'm getting. INSERT INTO ( , , ,...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.