June 18, 2010 at 3:16 am
I'm semi-new to sql, and now I'm trying to select every DateStartTime (a date and time) from tblOccasion that are five days or less after/later than the current date. I've tried to statement below, and get the error message: Incorrect syntax near the keyword 'CURRENT'.
"SELECT dateStartTime FROM Occasion WHERE dateStartTime <= (CURRENT DATE + integer '5')"
Thankful for any help!
June 18, 2010 at 3:32 am
That doesn't look like SQL Server syntax. CurrentDate isn't a SQL function and that 'integer 5' is also not t-SQL.
The SQL Server way of doing that would be
SELECT dateStartTime FROM Occasion WHERE dateStartTime <= DATEADD(dd,5,Getdate())
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
June 18, 2010 at 4:22 am
It seems to be working, thanks!!
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply