LoriLHS
asked on
How do I pull records for the current year using the system date?
How do I pull records for the current year (2011) using the system date? And for the prior and current year (2010 & 2011) using the system date.
Did you need records between 1 April to 31 March.
ASKER
All of current year up til today.
It means, suppose todays u need records from 1 jan 2011 to 5 april 2011.
Use GETDATE()
select * from yourtable
where DATEPART(YEAR, yourdatefield) = DATEPART(YEAR, GETDATE())
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you.
try this one...
select * From T_table
where d_column between convert( datetime , convert(char(4),year(getda te())) +'-'+ convert(char(4), '1')+'-' + convert(char(4),'1') )
and convert( datetime , convert(char(4),year( getdate())) +'-'+ convert(char(4),month( getdate()))+'-' + convert(char(4),day( getdate())) )
select * From T_table
where d_column between convert( datetime , convert(char(4),year(getda
and convert( datetime , convert(char(4),year( getdate())) +'-'+ convert(char(4),month( getdate()))+'-' + convert(char(4),day( getdate())) )