Nemo - 4828
SSC Eights!
Points: 992
More actions
September 16, 2009 at 7:42 am
#74098
Hi,
I have two variables declared,
@BeginDate datetime
@EndDate datetime
I need to set the first variable to 01/01 of every year..ie if the current year is 2009 then @begindate should be 01/01/2009,
if its 2010 the @BeginDate should be set to 01/01/2010. The year part should dynamically change depending on the current year.
Please advice..
Thanks in advance,
Nemo-4828
matt6288
SSCertifiable
Points: 5058
September 16, 2009 at 7:57 am
#1054448
This should work but I don't have a SQL 7 or 2000 instance to test on.
DECLARE @BeginDate DATETIME
DECLARE @EndDate DATETIME
SELECT @BeginDate = DATEADD(YEAR,DATEDIFF(YEAR,0,GETDATE()),0)
SELECT @BeginDate
September 16, 2009 at 8:14 am
#1054463
It works....
Thanks Matt
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply