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 |
|
u2p_inst
Yak Posting Veteran
78 Posts |
Posted - 2003-09-08 : 01:13:57
|
| i have field with the type is varchar(255)and i execute the query:select [id],Cast(col019 as DateTime) from tbl_AccOpni have ann error message'Syntax error converting datetime from character string.'Is possible to converting datetime from character string?oh |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2003-09-08 : 02:20:00
|
| Yes - what format is the string?Look at the convert fuction and use the appropriate style.==========================================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. |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2003-09-08 : 10:10:03
|
If it can happen, it will happen...If you allow for non date values* in a varchar...you'll get them...find out where they are and eliminate or code for them..SELECT * FROM tbl_AccOpn WHERE ISDATE(col019) <> 1 * (question: is zero a non date value?...not that debate again...)Brett8-)SELECT @@POST=NewId()That's correct! It's an AlphaNumeric! |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2003-09-08 : 10:10:56
|
| SELECT ISDATE(Getdate())SELECT ISDATE(0)Brett8-)SELECT @@POST=NewId()That's correct! It's an AlphaNumeric! |
 |
|
|
dsdeming
479 Posts |
Posted - 2003-09-08 : 13:31:29
|
| For what it's worth, if you ever need to do date calculations ( last 30 days, older than i year, etc. ), you can save yourself a world of grief if you store your data in datetime columns rather than varchars. It saves you having to convert strings to dates and back.Dennis |
 |
|
|
ValterBorges
Master Smack Fu Yak Hacker
1429 Posts |
Posted - 2003-09-08 : 15:32:00
|
| To add to dsdeming if you store your dates in iso format then conversions in sql server are implicit. |
 |
|
|
|
|
|