var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: Set vars in stored proc to first and last day of year
Nice simple question from someone making there way with their first stored prcoedure. I am editing a procedure where I have hardcoded the two date variables to 01/01/06 and 31/12/06.
How could I make this year sensitive so that next year the variables are set to 01/01/07 and 31/12/07 automatically.
set @firstday = DATEADD(yyyy, DATEDIFF(yyyy, 0, GETDATE()), 0)
set @lastday = DATEADD(yyyy, 1, @firstday) - 1
set variable =cast(cast(year(getdate()) as varchar)+ '-01-01' as datetime)
set variable =cast(cast(year(getdate()) as varchar)+ '-12-31' as datetime)
current year start and end
with one cast less and maybe more "readable" for you?
year(getdate()) returns the current year.
declare @Fdoy datetime, @Ldoy datetime
set @Fdoy = '01-jan-' + cast(year(getdate()) as varchar)
set @Ldoy = '31-dec-' + cast(year(getdate()) as varchar)
the versions which employ string handling are much slower than my method
Many thanks for the feedback.