选择特定月份的日期 [英] select date of perticular month

查看:112
本文介绍了选择特定月份的日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有日期列表:



01/02/2013

02/02/2013

03/02/2013

04/02/2013

05/02/2013

01/03/2013

02/03/2013

03/03/2013





来自此我必须选择仅限第二个月的日期列表(2月份的奖励)。

什么是查询?

解决方案

试试这个:

  SELECT  MyDateTimeColumn  FROM  TableName  WHERE  MONTH(MyDateTimeColumn)= 2   -    2月 







--Amit


尝试这个它正在工作





 选择 * 来自 tableName 其中 MON TH(columnName)= 2 







注意:表的日期列应采用日期时间格式


如果你的列表已经从数据库中获取,你的列表实现了像List<>这样的IEnumearble(或IQueryable)接口。或IEnumerable<>它是一个DateTime结构列表然后你可以使用LINQ,如:



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







var query2 =来自_list中的i,其中i.Month == 2选择i;

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?

解决方案

Try this:

SELECT MyDateTimeColumn FROM TableName WHERE MONTH(MyDateTimeColumn)=2 --February




--Amit


Try this It''s working


select * from tableName where MONTH(columnName)=2




Note : Datecolumn of your table should in datetime format


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;


这篇关于选择特定月份的日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆