August 27, 2010 at 9:13 am
HI, does any one know how to get the last date of the current year and the first date of the current year - needto use as defaults in a parameter
August 27, 2010 at 9:27 am
In T-SQL, this will work:
select [StartOfYear] = DATEADD (year, datediff(year, 0, getdate()), 0),
[EndOfYear] = dateadd(day, -1, DATEADD(year, datediff(year, 0, getdate()+1), 0))
Reporting Services is very similar, but I won't have access to it to play around and try it out until tonight.
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
August 27, 2010 at 11:59 am
Try this:
=CDate("1/1/" & Str(Year(Today())))
or
=CDate("1/1/" & Str(Year(Now())))
For the last day just replace the beginning
=CDate("12/31/" & Str(Year(Today())))
August 27, 2010 at 10:37 pm
WayneS (8/27/2010)
In T-SQL, this will work:
select [StartOfYear] = DATEADD (year, datediff(year, 0, getdate()), 0),
[EndOfYear] = dateadd(day, -1, DATEADD(year, datediff(year, 0, getdate()+1), 0))
Reporting Services is very similar, but I won't have access to it to play around and try it out until tonight.
For end of year: DATEADD(year, DATEDIFF(year, -1, getdate()) + 1, -1)
Jeffrey Williams
“We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”
― Charles R. Swindoll
How to post questions to get better answers faster
Managing Transaction Logs
August 31, 2010 at 3:24 am
Thanks all perfect
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply