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
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Msg 242, Level 16, State 3 When Running SP

Author  Topic 

gavinjb
Starting Member

34 Posts

Posted - 2009-07-30 : 05:05:42
Hi, When I am trying to run a stored Procedure that takes a DateTime as an input Parameter I am getting the following error and can't work out what I am doing wrong can anyone help.


Msg 242, Level 16, State 3, Procedure EMA, Line 15
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.


To run the SP I am using the following SQL


EXEC EMA '01-Aug-2009'


if I run DBCC UserOptions I find that my date format is set to mdy

any ideas.

Thanks,


Gavin,

rajdaksha
Aged Yak Warrior

595 Posts

Posted - 2009-07-30 : 05:40:13
quote:
Originally posted by gavinjb

Hi, When I am trying to run a stored Procedure that takes a DateTime as an input Parameter I am getting the following error and can't work out what I am doing wrong can anyone help.


Msg 242, Level 16, State 3, Procedure EMA, Line 15
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.


To run the SP I am using the following SQL


EXEC EMA '01-Aug-2009'


if I run DBCC UserOptions I find that my date format is set to mdy

any ideas.

Thanks,


Gavin,


Hi

This error message appears, when SQL Server tries to convert a string to a DATETIME value and encounters that the resulting value is outside the valid range for DATETIME values.

SQL Server offers a range of DATETIME values between 01/01/1753 and 12/31/9999. Values that are beyond this range cannot be stored in a column of the DATETIME type and any attempt raises this error.


-------------------------
R..
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-07-30 : 05:52:14
What happens when you run this?

EXEC EMA '20090801'


Madhivanan

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

- Advertisement -