Re: FAIL TO USE GETDATE() ON A FUNCTION

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

From: Tibor Karaszi (tibor_please.no.email_karaszi_at_hotmail.nomail.com)
Date: 11/25/04


Date: Thu, 25 Nov 2004 13:40:20 +0100

Search the archives and you will find workarounds and the reason for this. One workaround is to
create a view in which you call getdate and use that view. But be aware that this makes getdate
non-atomic and non-deterministic.

-- 
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Comfort P." <comfort.peter@stcl.com> wrote in message news:u3hj6nu0EHA.3468@TK2MSFTNGP14.phx.gbl...
> I have created my function call a getdate(). After running my function I get
> the following error message:
> INVALID USE OF GETDATE() IN A FUNCTION.
> Is there any alternative to this as I need to know the current date in my
> function?
>
>


Relevant Pages

  • Re: Calling Function within a function
    ... getdate() which cannot be used. ... There are workarounds but yet they are not ... You can always ping into SQL Server ... > Means i am calling GetDate() function with in a user defined function, ...
    (microsoft.public.sqlserver.programming)
  • Re: customize getdate() function
    ... > imagine that there was a good reason to require this limitation. ... SELECT col1, GETDATE() FROM tbl_many_rows ...
    (microsoft.public.sqlserver.programming)
  • Re: ISO time/date client
    ... > b> machine's clock accordingly? ... > Try Michael Hamilton's `getdate' program. ... Is there any reason why no-one has suggested `ntpdate'? ...
    (comp.os.linux.misc)
  • Re: GETDATE() in a function ???
    ... That article mentions using a view to encapsulate getdate(). ... treat that with caution - there is a reason why getdateis not allowed in a function and fooling the optimiser like this can easily cause incorrect results from a query. ...
    (microsoft.public.sqlserver.programming)