Click here to Skip to main content
15,899,937 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i have a table named Tbl_Product
having columns (id,PName,PTime)----

(1,Nokia,1/20/2012 7:02:09 PM)
(2,Samsung,1/21/2012 7:02:09 PM)
(3,Micromax,1/20/2012 7:02:09 PM)
(4,Tablet,1/21/2012 7:02:09 PM)
(5,Pendrive,1/20/2012 7:02:09 PM)
now i want to select data in a such manner date shoud be 1/20/2012

compare only 1/20/2012 and bind it to GridView.......help me....
Posted

Try:
SQL
SELECT * FROM Tbl_Product WHERE CAST(PTime AS Date)='2012-01-20'
 
Share this answer
 
Comments
PKriyshnA 20-Jan-12 10:35am    
thnx a lot ....
PKriyshnA 20-Jan-12 11:17am    
vary excellent
i'd use
SELECT * 
FROM Tbl_Product 
WHERE Year(PTime) = 2012
AND Month(PTime) = 1
AND Day(PTime) = 20
 
Share this answer
 
Comments
bbirajdar 20-Jan-12 10:46am    
excellent one . My +5
select Convert(nvarchar(10),date,101) as date from date1
 
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