Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Blastrix
Posting Yak Master
208 Posts |
Posted - 2003-09-10 : 12:41:08
|
| I realize that GetDate() and quite a few other functions can not be called from inside of a UDF, but does anyone know why? It seems like such a strange limitation that a UDF can't use other system functions.Thanks,Steve |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2003-09-10 : 12:49:12
|
| a UDF must be deterministic, meaning that given the same inputs, it always returns the same output.The GetDate() function is nondeterministic.- Jeff |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2003-09-10 : 12:54:07
|
| Why not pass Getdate() in as a parameter?Brett8-)SELECT @@POST=NewId()That's correct! It's an AlphaNumeric! |
 |
|
|
Shaner
Starting Member
9 Posts |
Posted - 2003-09-11 : 10:28:05
|
| You can also set up a view as follows. Then access the date from the view instead. Sort of messy but a good workaround.----------------------------------------CREATE VIEW dbo.vwGetUTCDateASSELECT GETUTCDATE() AS CurrentDate--------------------------------------------------------------------------------CREATE FUNCTION [dbo].[fnCalcElapsedTime] (@TimeIn datetimeRETURNS decimal(15,2) AS BEGIN DECLARE @Elapsed decimal(15,2), @UTC datetimeSELECT @Elapsed = CONVERT(decimal(15,2), ROUND( (CONVERT(decimal(15,2),(DATEDIFF(mi,@TimeIn,CurrentDate)))/60) ,2)) FROM vwGetUTCDateRETURN @ElapsedEND---------------------------------------- |
 |
|
|
|
|
|
|
|