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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2001-06-13 : 22:05:10
|
Samir writes "If I use this script:
Declare @MyDate DateTime Set @MyDate = '6/1/2001'
DECLARE @DateOnly DateTime SELECT @DateOnly = CONVERT(DateTime,CONVERT(VARCHAR(10),@MyDate,101)) SELECT * FROM MyTable WHERE TableDate = @DateOnly
there is no problem. --------------------------------------------------- but, if I use this script:
Declare @str varchar(300) @MyDate DateTime AS DECLARE @DateOnly DateTime SELECT @DateOnly = CONVERT(DateTime,CONVERT(VARCHAR(10),@MyDate,101)) @str = 'SELECT * FROM MyTable WHERE TableDate < ' + @DateOnly Exec(@str)
I get this error: Server: Msg 241, Syntax error converting datetime from character string.
Please help Thanks very much" |
|
|
|
|
|