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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 DateTime out of range

Author  Topic 

golyath
Starting Member

21 Posts

Posted - 2007-10-24 : 07:25:24
Hi,

I have dates stored in an SQL Table and they have been allowed in the UK format..
e.g 30/12/2004 00:00:00

But when i then use this WHERE clause it errors and says:
"SQL Server The conversion of a char to a datetime data type resulted in an out-of-range datetime value"

WHERE date = '30/12/2004 00:00:00'

When i switch the month with the day (12/30/2004) its fine but doesnt select teh date.

How can i do this in the UK Format?

Thanks

shallu1_gupta
Constraint Violating Yak Guru

394 Posts

Posted - 2007-10-24 : 07:37:46
use convert method..
WHERE date = convert(datetime, '30/12/2004 00:00:00', 131)
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-10-24 : 07:41:42
what is the data type of the date column ?


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

elwoos
Master Smack Fu Yak Hacker

2052 Posts

Posted - 2007-10-24 : 07:50:31
If your date column is of DATETIME type you may want to consider using ISO format in your query (YYYYMMDD) e.g. WHERE date = '20041230'


steve

-----------

Don't worry head. The computer will do all the thinking from now on.
Go to Top of Page

golyath
Starting Member

21 Posts

Posted - 2007-10-24 : 07:59:42
The Type is datetime,

I will try your suggestions and report back thanks
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-10-24 : 08:09:15
Run

dbcc useroptions

to see the current date format of the server
But as said use YYYYMMDD HH:MM:SS format

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -