Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do I return anything in year 2005

Status
Not open for further replies.

DougP

MIS
Dec 13, 1999
5,985
US
Select * From myTable where SomeDate = '%/%/2005'

DougP, MCP, A+
 
Select * from myTable
Where right(convert(varchar(10),somedate,101),4) = '2005'

Jim
 
Another Way...
Code:
Select DATENAME(yy ,somedate) as 'Somedate'
from mytable
Where DATENAME(yy ,somedate) = '2005'
 
I would have done this the same way the cLFlaVA shows. But since we're getting in to multiple ways...

Select * From myTable where SomeDate Like '%2005%'

The problem with this method is that there will be an implicit data type conversion (from DateTime to varchar) so that the like comparison can work.

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top