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.
| Author |
Topic |
|
Gigi
Starting Member
23 Posts |
Posted - 2009-03-31 : 08:53:24
|
| I have a column with 'varchar' data type, that contains a date as 20090331. What i want to do is update this table and break the date like 2009-03-31 and then add 'T00:00:00'. So the query should look what the cuurent value of the column is (lets call this column DateColumn) and then split the date and add the time string. So after the update statement is executed, the data in the column should look like 2009-03-31T00:00:00 (based on what the value cotained in the DateColumn at the time of the run).I am very new to SQL development so any help would be greatly appreciated.thank you |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-03-31 : 09:09:30
|
-- For confirmationSELECT Col1,STUFF(STUFF(Col1, 5, 0, '-'), 8, 0, '-') + 'T00:00:00'FROM Table1-- For updateUPDATE Table1SET Col1 = STUFF(STUFF(Col1, 5, 0, '-'), 8, 0, '-') + 'T00:00:00' E 12°55'05.63"N 56°04'39.26" |
 |
|
|
Gigi
Starting Member
23 Posts |
Posted - 2009-03-31 : 09:14:11
|
| that worked perfectly....thanks a lot Peso |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-03-31 : 09:31:09
|
| Why dont you use proper DATETIME column to store dates?MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|