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.
ZYTThe 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.
-PatP|||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.
http://www.aspfaq.com/show.asp?id=2439
No comments:
Post a Comment