c# - How to query records based on date -
i have datatable 5 columns type of int, string , datetime. have written linq query filter records date. how records today , yesterday?
var data = _dtall.asenumerable() .where(datas => datas.field<datetime>("date") == datetime.now.date) .select(datas => new { ---})
i not getting records. record @ 14/05/2013 10:00 am. dont need query time, need query date. appriciated.
the dates of yesterday , today dates between midnight yesterday (including) , midnight tomorrow (excluding):
var upperbound = datetime.today.adddays(1); var lowerbound = datetime.today.adddays(-1); var data = _dtall.asenumerable() .where(datas => datas.field<datetime>("date") < upperbound) && datas.field<datetime>("date") >= lowerbound) .select(datas => new { ---})
Comments
Post a Comment