How to get the current server date and time inside a User Defined Function on SQL Server
User Defined Function cannot contain calls to non-deterministic functions, so a call to GETDATE() cannot be executed inside a function.
To get the current time and date, this is usually good enough:
SELECT MAX(last_batch) FROM master.dbo.sysprocesses
