Friday, March 9, 2012

Get the current year using SQL

Hi everyone,

Currenly, I'm getting the current year in my code, and passing this to my stored procedure.

I'm sure there's a way just to get the current year (ie '2004') just by using SQL.

I was just about to post this question here when I did a bit more digging around and found my solution:

DATEPART(yyyy, GETDATE())

This will get the year.

Hope this helps someone searching for the answer!Also, YEAR(GetDate()) will get you the year.|||> Also, YEAR(GetDate()) will get you the year.

That looks even better!!

Cheers

No comments:

Post a Comment