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
 Date issue

Author  Topic 

Sean_B
Posting Yak Master

111 Posts

Posted - 2007-07-05 : 03:16:28
Hi,

We've just moved a database from a 32 bit to a 64 bit server.

I've been defaulting an end date to '9999-12-31 00:00:00.000'
which works fine in the 32 bit environment, and the data already populated in the columns have moved across to the 64 bit server ok, but the new server won't allow for an insert of this value.

I get the following error if I try

INSERT INTO seantemp(mydate) SELECT '9999-12-31 00:00:00.000'

Msg 242, Level 16, State 3, Line 1
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
The statement has been terminated.

I realise this may have nothing to do with the 64 bit environment.

Can anyone help ?







Sean

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-07-05 : 03:29:31
1) Try first SET DATEFORMAT YMD before inserting
2) If that doesn't help ,try INSERT INTO seantemp(mydate) SELECT '99991231 00:00:00'
3) And last, try INSERT INTO seantemp(mydate) SELECT 'Dec 31, 9999'

Do you still get same error?


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

Sean_B
Posting Yak Master

111 Posts

Posted - 2007-07-05 : 03:47:42
Thanks, thats the problem.
I've just discovered the date format on the server has changed, unfortunately I've not specifically specified the format in a number of different places in my procedures, I've just relied on the server format.

I guess that I should always specify the date format using a convert statement.

Sean
Go to Top of Page
   

- Advertisement -