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 |
|
MirandaJ
Starting Member
35 Posts |
Posted - 2007-12-04 : 17:19:29
|
| I recently wrote a stored procedure to add the date and time to an existing table. The date is being stored as Oct 29 2007 5:37PMInstead of as 10/29/2007 5:37:23 PMThe column is a varchar(24) data type and I use GETDATE() in the stored procedure to supply the date. What do I need to do to change to get this to save the date as mm/dd/yyyy Miranda |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-12-04 : 17:20:44
|
Why are you using VARCHAR in the first place?Use DATETIME and you will never have to worry about format. E 12°55'05.25"N 56°04'39.16" |
 |
|
|
MirandaJ
Starting Member
35 Posts |
Posted - 2007-12-04 : 17:23:26
|
quote: Originally posted by Peso Why are you using VARCHAR in the first place?Use DATETIME and you will never have to worry about format.
as I said it is being written 'to an existing table' and I did not write the database there are hundreds of thousands of records in this dbMiranda |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-12-04 : 17:26:12
|
Use CONVERT function. E 12°55'05.25"N 56°04'39.16" |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-12-05 : 02:16:40
|
| The best approach, IMO, is to create new column with DATETIME datatype and update existing dates to it and use that new column thereafterMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|