Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using a system date variable within a Function

Status
Not open for further replies.

Middlej

MIS
Jan 4, 2002
4
US
Hello everyone...here's a little problem I have. I would like to use a GETDATE()-like function within a function, except I know I can't use GETDATE() within a function I create. What other options can I use? I have tried this:



select dbo.myfunction(mydate)
from
(select
getdate() as mydate
from dbo.mytable) as mydata


(Where myfunction is the function I call, mydate is the alias for the getdate() function)

...but this means that I must go through an extra step in order to pass the date variable into the function. I'd like to do this in just the function alone. Any suggestions?

Thank you,

Middlej
 
You can't use getdate within a function. You can pass it to a function.

select dbo.myfunction(getdate())
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top