怎么查询DateTime数据类型的日期(不考时间)否存在
如何查询DateTime数据类型的日期(不考时间)否存在?
2015/10/4 23:19:08
2015/10/4 23:19:08
2015/10/6 23:22:44
2015/10/6 23:22:44
请问题如何查fDate的值为2015/10/6是否存在?
DateTime fDate = new DateTime();
DateTime.TryParse(q, out fDate);
Object result = null;
if (db_OA.SMSsendRecords.Any(a =>(a.nextMaintenanceDate >= fDate && a.nextMaintenanceDate < fDate.AddDays(1))))
{
result = new { msg = "已结算.未结账" };
}
------解决思路----------------------
------解决思路----------------------
如果你的数据默认不是日期,那你需要先转化成DateTime
------解决思路----------------------
2015/10/4 23:19:08
2015/10/4 23:19:08
2015/10/6 23:22:44
2015/10/6 23:22:44
请问题如何查fDate的值为2015/10/6是否存在?
DateTime fDate = new DateTime();
DateTime.TryParse(q, out fDate);
Object result = null;
if (db_OA.SMSsendRecords.Any(a =>(a.nextMaintenanceDate >= fDate && a.nextMaintenanceDate < fDate.AddDays(1))))
{
result = new { msg = "已结算.未结账" };
}
------解决思路----------------------
DateTime fDate = new DateTime(2015, 10, 6);
Object result = null;
if (db_OA.SMSsendRecords.Any(a => a.nextMaintenanceDate.Date == fDate))
{
result = new { msg = "已结算.未结账" };
}
------解决思路----------------------
如果你的数据默认不是日期,那你需要先转化成DateTime
------解决思路----------------------
//测试数据
List<DateTime> l = new List<DateTime>() {
DateTime.Now,
DateTime.Parse("2015-07-13 12:13:00"),
DateTime.Parse("2015-07-13 12:13:00"),
DateTime.Parse("2015-07-13 12:13:00") };
//时间
DateTime d = DateTime.Now.Date;
var q = l.Where(x => x.Date == d).ToList();
Console.WriteLine(q[0]);
Console.ReadLine();