Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2003

    Unanswered: Cannot use GETDATE ( ) in a function?

    I want to use GETDATE ( ) in a user defined function for date comparing. When I compile the function, got the error:

    Invalid use of 'getdate' within a function.

    How to get the current date in a function? Any suggestion will be appreciated.


  2. #2
    Join Date
    Feb 2004
    In front of the computer
    Provided Answers: 54
    The way that SQL 2000 impliments User Defined Functions (UDFs) requires that the functions be deterministic, in other words that for a given set of function arguments the UDF will always return the same result. GetDate() is non-deterministic because it should return a different value every time it is called. Because of that, you can't call GetDate() within a SQL 2000 UDF, although you can use GetDate() as an argument to one and use that argument any way you see fit.


  3. #3
    Join Date
    Jun 2003

    Thumbs up

    you cannot use a non-deterministic function within a UDF.getdate() is a non deterministic function. So better pass getdate() value as parameter to ur function .There are otherways too.check this link for more details.
    Last edited by mallier; 12-22-05 at 10:19.
    I love cursor,though I never use it.Cos' I dont want to misuse it.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts