Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Format date/time field

Author  Topic 

Nomadic
Starting Member

2 Posts

Posted - 2008-10-06 : 16:41:19
I am trying to format a date/time column for company table.
Records that were uploaded from our old database has the following format
20080117 (no spaces , no dashes , no nothing in between, it is a string)
New records that're created in the new database has the following format
Jan 17 2008 4:26PM

How can I format this column so all of them look the same?

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-10-06 : 16:42:29
CONVERT(DATETIME, Col1, 112)



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-10-06 : 16:43:30
They will converted automatically when inserted into new column which has datetime datatype.



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-10-07 : 06:08:10
Use Datetime datatype to store dates and leave front end application do the formation

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Nomadic
Starting Member

2 Posts

Posted - 2008-10-07 : 09:10:08
Thanks for your answers Peso and Madhivanan.
Peso,
How am I going to insert them into new column which has datetime datatype.
?
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-10-07 : 09:24:49
insert into target_table(cols, date_column)
select cols,CONVERT(DATETIME, Col1, 112) from source_table


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -