how to use CURRENT DATE correctly?

  • 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!

  • 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

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • 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