PRB: DATEADD Doesn't Work When Using a Variable as a DateID: Q47048
|
The use of a variable as a date in the DATEADD command can result in an error message of "Msg 242, Level 16, State 0:," stating that an out of range conversion was attempted.
This problem can be corrected by ensuring the variable is correctly declared as datetime.
declare @valdate char(10)
select @valdate=convert(datetime,'07/07/57')
select dateadd(day,15,@valdate)
go
Msg 242, Level 16, State 0:
select dateadd(day,15,'07/07/57')
go
declare @valdate datetime
select @valdate=convert(datetime,'07/07/57')
select dateadd(day,15,@valdate)
go
Additional query words: Transact-SQL
Keywords : kbtool SSrvBCP
Version : 4.2
Platform : OS/2
Issue type :
Last Reviewed: March 6, 1999