Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In database, date is stored in timestamp format, while fetching I need to fetch the records with given condition like.
SQL
select * from projects where week(enddate) = 6 and year(enddate) = 2013

Its not working. Please help me how to compare and fetch the records.
Posted
v4
Comments
Sandeep Mewara 16-Feb-13 6:50am    
Elaborate not working. Query looks ok and should get week and year as per need.

1 solution

SQL
SELECT * FROM projects WHERE CONVERT(INT,DATEPART(WEEK,enddate)) =6 and
CONVERT(INT,DATEPART(year,enddate)) = 2013
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900