Variable

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Justin Drennan (justin_at_nospam.com)
Date: 10/01/04


Date: Fri, 1 Oct 2004 12:00:59 +0200

How would I use a variable to select a time period as shown below. The
example below returns error: Incorrect syntax near '@Timeperiod'

Am i missing something here?

Declare @Timeperiod as int

set @Timeperiod = 7

Select * from X
where (datediff(d, usdateopened, getdate() @Timeperiod) = 0)

thanks



Relevant Pages

  • Re: Another Tricky Problem I am Messing With (Not Homework)
    ... joebenjamin wrote: ... am not sure how to go about this, but there is something I am missing ... Need to read in a time period from the keyboard (for example 1.2 seconds, ... int main ...
    (comp.lang.c)
  • Re: BS on ult hist bk - extras "the best"
    ... at least we're beginning to dialogue. ... You keep missing my ... > qualifier that they were the "best 7" during that time period. ...
    (rec.sport.disc)
  • Re: Stuck on Earth
    ... You might also note that the Doc is trying to get Tegan home for the ... first four stories and keeps missing the time period. ...
    (rec.arts.drwho)
  • Re: sql command error
    ... Incorrect syntax near ';' ... also there is a missing " before the CAST:) ... "Dan" wrote: ...
    (microsoft.public.sqlserver.programming)
  • Re: User Define Functions- Incorrect syntax near (
    ... In my actual code i am not missing any paranthesis. ... SELECT TotalSize FROM dbo. ... Line 9: Incorrect syntax near '('. ...
    (microsoft.public.sqlserver.programming)