Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have list of dates :

01/02/2013
02/02/2013
03/02/2013
04/02/2013
05/02/2013
01/03/2013
02/03/2013
03/03/2013


from this i have to select list of dates of second month only(meance in february).
what is query for that?
Posted
Comments
Shubh Agrahari 20-Feb-13 3:53am    
Is you using real format of date time or just using simple string for list box...???

Try this:
SQL
SELECT MyDateTimeColumn FROM TableName WHERE MONTH(MyDateTimeColumn)=2 --February



--Amit
 
Share this answer
 
Try this It's working


SQL
select * from tableName where MONTH(columnName)=2



Note : Datecolumn of your table should in datetime format
 
Share this answer
 
If your list already fetched from the DB and your list implements the IEnumearble (or IQueryable) interface like List<> or IEnumerable<> and it is a list of DateTime struct then you can use LINQ like:

var query = _list.where(a => a.Month == 2);

OR

var query2 = from i in _list where i.Month == 2 select i;
 
Share this answer
 
v2

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