Re: Syntax problem?

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

From: Aaron [SQL Server MVP] (ten.xoc_at_dnartreb.noraa)
Date: 09/01/04


Date: Wed, 1 Sep 2004 17:14:50 -0400

Put the date into a variable.

DECLARE @d1 SMALLDATETIME, @d2 SMALLDATETIME
SET @d1 = GETDATE()-30
SET @d2 = GETDATE()
SELECT * FROM GetNewClients(@d1, @d2)

And please stop using ambiguous date formats. If you're going to allow the
engine to implicitly convert your date, at least prevent it from screwing it
up. Use YYYYMMDD.

-- 
http://www.aspfaq.com/
(Reverse address to reply.)
"Eddie" <Eddie@discussions.microsoft.com> wrote in message
news:E298954B-500E-488A-ABA4-16689462F8F7@microsoft.com...
> I'm having trouble with something which I think I shouldn't be having
trouble
> with...
>
> I'd like to do a:
>
> select * from GetNewClients(getdate() - 30, getdate())
>
> But I get a:
>
> Server: Msg 170, Level 15, State 1, Line 1
> Line 1: Incorrect syntax near '('.
>
> However, this and kin work: select * from GetNewClients('1/1/2004',
> '6/1/2004'), etc..
>
> What's going on here?
>
> Thanks.
>
> Eddie


Relevant Pages

  • Re: Looking for a number of days before or after a date in database
    ... or a field that has a date but is type nvarchar? ... birthdate. ... smalldatetime if needed. ... ....Where DateDiff(dd, GetDate(), DOB)< Between 1 And 10 ...
    (microsoft.public.vb.general.discussion)
  • Re: Using GETDATE() in WHERE clause
    ... they would need to match to the minute (if GETDATE converts to smalldatetime). ... The method of counting crossed boundaries such as minutes, seconds, and milliseconds makes the ... The result is a signed integer value ...
    (microsoft.public.sqlserver.programming)
  • Re: GetDate() in User Defined Functions, Parameters in View
    ... Then just use that new parameter as your getdate() ... I prefer the UDF ... > DateValue smalldatetime) ... > SELECT top 10000 DateValue ...
    (microsoft.public.sqlserver.server)
  • Re: Default values
    ... CREATE TABLE foo(dt SMALLDATETIME DEFAULT GETDATE()) ... Note that a time portion will still be stored, ... "Jeff Cichocki" wrote in message ...
    (microsoft.public.sqlserver.server)
  • Re: How do I Convert a Date/Time Field to Just a Date Field?
    ... SELECT GETDATE() ... > In a SQL Server 2K table, I have a field formatted as a SMALLDATETIME ... > mydatetime, 102), but it doesn't seem to drop the hours and minutes. ...
    (microsoft.public.sqlserver.programming)