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 |
|
esthera
Master Smack Fu Yak Hacker
1410 Posts |
Posted - 2007-10-12 : 04:50:16
|
| i have a nvarchar filed that has dates in the format of day-month-yearwhere today would be 12-10-2007but Feb 8 ,2007 would be 8-2-2007 (just on character)can I convert this to an sql date when retrieving my query?can anyone help me with this? |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-10-12 : 04:58:37
|
| 1 Always use proper DATETIME datatype to store dates2 It is your front end application where you should do the formation there3 Read about convert function in sql server help fileMadhivananFailing to plan is Planning to fail |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2007-10-12 : 04:59:52
|
You should add a column which has a DateTime datatype, or convert that column to DateTime.You can convert the dates from String to DATETIME datatype (and provide a "day-month-year" hint), and then you can convert them to whatever format you want - preferably using your front end application rather than doing that conversion on the ServerSELECT CONVERT(Datetime, MyDate, 104)FROM( SELECT [MyDate] = '12-10-2007' UNION ALL SELECT [MyDate] = '8-2-2007') AS X Kristen |
 |
|
|
|
|
|