February 10, 2010 at 7:08 am
Hello Everyone
Is anyone snowed in like me?
I am trying to add a single day to a date data type value
DECLARE @TodaysDate Date
DECLARE @TomorrowsDate Date
SET @TodaysDate = 2010-2-14
SET @TomorrowsDate = (@TodaysDate + 1)
I am receiving this error:
Operand type clash: date is incompatible with int
I cannot find, or do not understand what the BOL states about this conversion.
Can someone point me in the correct direction?
Thanks
Andrew SQLDBA
February 10, 2010 at 7:17 am
February 10, 2010 at 7:18 am
AndrewSQLDBA (2/10/2010)
Hello EveryoneIs anyone snowed in like me?
I am trying to add a single day to a date data type value
DECLARE @TodaysDate Date
DECLARE @TomorrowsDate Date
SET @TodaysDate = 2010-2-14
SET @TomorrowsDate = (@TodaysDate + 1)
I am receiving this error:
Operand type clash: date is incompatible with int
I cannot find, or do not understand what the BOL states about this conversion.
Can someone point me in the correct direction?
Thanks
Andrew SQLDBA
try: set @TomorrowsDate = dateadd(dd, 1, @TodaysDate)
Edit: Also make this change: SET @TodaysDate = '2010-2-14'
February 10, 2010 at 8:17 am
Whoooops!
I forget the quotes around the date. But you get the jest of it. I know the date is supposed to have quotes.
Thanks Everyone. I will try your suggestions
Is that listed in the BOL? Or did I just not see it in the Date & Time data type section?
Andrew SQLDBA
February 10, 2010 at 8:22 am
dateadd in BOL
and a great post about dates in T-SQL
February 10, 2010 at 8:25 am
Thanks, I hope this can help someone else also.
I will go back and read it again. Maybe i looked right over it
Andrew SQLDBA
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply