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 |
|
miranduh8
Starting Member
4 Posts |
Posted - 2006-06-29 : 12:16:37
|
| I am needing to reformat two dates in a SQL query. The first date currently is formatted like this: Dec 23 2005 7:29PM and I am needing it like this: 2005-12-23. The second date currently is formatted like this: 2006-06-12 10:59:26 and I am needing to remove the time. I am needing to change the formatting directly in a query.Any help you could give would be greatly appreciated.MirandaMiranda Hoskins |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2006-06-29 : 12:20:14
|
| I assume these are character strings as datetimes have the format of 2 binary values.Have a look at the convert functionselect convert(varchar(10),convert(datetime, @dte), 121)select convert(varchar(10),convert(datetime, @dte, 121), 121)or justselect left(@dte, 10)==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-06-30 : 02:07:00
|
| >>The first date currently is formatted like this: Dec 23 2005 7:29PM and I am needing it like this: 2005-12-23. What is the datatype of Date Column?If it is varchar datatype, then use proper DateTime datatype to avoid unnecessary conversionsMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|