473,657 Members | 2,497 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 7813
"pali" <pa**********@g mail.comwrote in message
news:11******** *************@e 34g2000pro.goog legroups.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,'abcdefg hijklmn')

Nov 8 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
45634
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
2105
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 -------+--------------------------- jim | 06/02/2004 00:05:52 jim | 06/02/2004 05:06:21
3
1457
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 to the date "12/28/2005". and I don't know how to concatenate them since "+" won't work after I convert them. Thanks, Alpha if (result == "00") { char separator = {','}; char intSep = {'.'};
12
2592
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 example: 21/05/2006
2
6998
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 convert all the general date data into short date format, so i would like to delete the time part of the data, it is any way i can do that ???? Thank you in advance and sorry for my english carlos
0
1670
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 using visual studio with following code on one of the dataset values with the help of following code SELECT Convert(varchar, Deliverydate, 103) as displayValue FROM TimePeriodOrderDeliveryDate.This only dispalys the date part from the ate time...
3
7147
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 to autoformat the contents of text entries in a GUI. For numbers, I'm converting the text representation to the appropriate type (using atoi, atof, ...) and converting the result back to text with the correct format (using sprintf). But this does...
5
32994
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 different answer: # db2 "VALUES INTEGER(CHAR(1964-07-20))"
1
1526
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 ( , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ) SELECT ., ., ., LTrim(.) AS Expr1, LTrim(.) AS , LTrim(.) AS , LTrim(.) AS , LTrim(.) AS , LTrim(.) AS , LTrim(.) AS , LTrim(.) AS , LTrim(.) AS ,...
0
8823
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7320
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4151
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4301
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1944
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1604
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.