goodk
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'
select * from myData Where FORMAT(myData.Date,'yyyy')
select * from myData Where year(myData.Date) <=2004
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
And since you including 2004, then it is january 2005
select * from myData Where year(myData.Date) <'20050101'
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')
You may also use DATEPART function like DATEPART(year, '12:11:28.123')
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
so all this gets obsolete?
http://www.w3schools.com/sql/sql_functions.asp
http://www.w3schools.com/sql/sql_functions.asp
ASKER
thanks Sharath