Sql

jonnymenthol

Registered User.
Local time
Today, 12:53
Joined
Oct 31, 2001
Messages
58
Hello,

I am in SQL enterprise manager, and trying to create a function which will give me, among other things, the current year.

The trouble I'm having is that I can't get the current date first.

I've tried :

SELECT GETDATE(), but I get an error saying invalid use of getdate in a function.

How can I get the current date in a function ?

Cheers,
J.
 
Try this...


Declare variables

e.g.

declare @TempDate datetime
declare @Year int


Assign values

@TempDate = GETDATE()
@Year = year(@TempDate)
 

Users who are viewing this thread

Back
Top Bottom