Click here to Skip to main content
15,883,766 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

How to retrieve Data from a table based on date?

Example: To retrieve orders(data) placed on jan-2013 from List of orders

Thanks in advance
Posted

in your case, SQL query should be like this...
SQL
select * 
from Orders 
where Month(OrderDate)=1 and Year(OrderDate)=2013

Happy Coding!
:)
 
Share this answer
 
C#
var SQL=string.Format("SELECT * FROM {0}",DateTime.Now.toString("MMM-yyyy"));
 
Share this answer
 
v2
Comments
ridoy 15-Jan-13 1:39am    
table_name absent there.
Suvabrata Roy 15-Jan-13 3:49am    
Actually I misunderstand it my assumption was he is asking about dynamic table name

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