0

I've been trying to get a list of records in a table where the column scheduledate > today(current date + time)

var billPays = from s in db.BillPays.SqlQuery("SELECT * FROM BillPay WHERE " + 1 + " = Active AND "  + DateTime.Now + " > ScheduleDate").ToList()
            select new BillPayModel
            {
                //model             
            };

             return View(billPays);

unfortunately this is not returning anything. Can some one help?

4

2 回答 2

0
string myQuery = string.Format("SELECT * FROM BillPay WHERE 1 = Active AND {0:s} > ScheduleDate", DateTime.now);
var billPays = from s in db.BillPays.SqlQuery(myQuery).ToList();
select new BillPayModel
        {
            //model             
        };

         return View(billPays);
于 2013-10-19T23:50:31.637 回答
0

尝试这个:

var billPays = from s in db.BillPays.SqlQuery("SELECT * FROM BillPay WHERE '"+ DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")+"' > ScheduleDate").ToList()

select new BillPayModel
    {
            //model             
    };
于 2013-10-19T15:42:04.750 回答