Link to home
Start Free TrialLog in
Avatar of goodk
goodkFlag for United States of America

asked on

not sure how to select certain years from the query? using MSSQL 2008 express

how? thanks
select * from myData Where FORMAT(myData.Date,'yyyy') <='2004'
Avatar of Pratima
Pratima
Flag of India image

select * from myData Where year(myData.Date) <=2004
Avatar of nativ
nativ

2004 will not be enough. You need it to be before the 1st of January.
And since you including 2004, then it is january 2005

select * from myData Where year(myData.Date) <'20050101'

Open in new window

For details on Year see here: http://msdn.microsoft.com/en-us/library/ms186313.aspx
You may also use DATEPART function like DATEPART(year, '12:11:28.123')
ASKER CERTIFIED SOLUTION
Avatar of Sharath S
Sharath S
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of goodk

ASKER

Avatar of goodk

ASKER

thanks Sharath