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 |
|
SimonGough
Starting Member
23 Posts |
Posted - 2002-01-17 : 07:39:36
|
| I am trying to cast a varchar field to a datetime type so I can check to see if something is greater than one date and less than another date.I am using: cast('17/01/02' as datetime)but I get the following error:The conversion of char data type to datetime data type resulted in an out-of-range datetime value.Can anyone help me solve this??Thnaks. |
|
|
Nazim
A custom title
1408 Posts |
Posted - 2002-01-17 : 07:51:44
|
| your dateformat settings are in mdy(the default). therefore when you are trying to convert '17/01/02' to Datetime, it takes month as 17 which is out of rage.Either you can Change your date settings or you can change the way you pass data to cast.eg:Set DateFormat ymdorcast('01/17/02' as datetime)HTH----------------------------------"True love stories don't have endings." |
 |
|
|
mphelps
Starting Member
12 Posts |
Posted - 2002-01-17 : 07:56:48
|
converting from varchar to datetime is an implicit conversion. there is no need to use the cast or convert functionMartin quote: I don't suffer from insanity, I enjoy every second of it
|
 |
|
|
Arnold Fribble
Yak-finder General
1961 Posts |
Posted - 2002-01-17 : 08:13:54
|
| Tell it explicitly what format it is expecting:select convert(datetime, '17/01/02', 3) |
 |
|
|
|
|
|