getdate() in UDF

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: EdAk (anonymous_at_discussions.microsoft.com)
Date: 03/16/04


Date: Tue, 16 Mar 2004 15:26:07 -0800

this question seems basic and trivial but i'm stumped

code snipped from UDF....

declare @rtnval int
set @rtnval = 0
if @pm < getdate() set @rtnval = 1

when attempting to create the UDF i get the following error.

"Invalid use of 'getdate' within a function"

why?
the only thing i want to do is test if the variable @pm is less than the current system date.

Ed.



Relevant Pages

  • Re: UDF Using GetDate() or Equivalent
    ... Some other suggestions were to pass the GetDate() as a parameter to the UDF. ... Alan ... > Declare a variable in your function and set it to the single value in the ...
    (microsoft.public.sqlserver.programming)
  • Re: Why Do I Get This Error
    ... You can't use GETDATE() in a function... ... > declare @rtnval int ... > Invalid use of 'getdate' within a function. ... how does one use the current system date in t-sql? ...
    (microsoft.public.sqlserver.programming)