简体   繁体   中英

how to convert datetime to date in DataView.RowFilter in c#?

I have to get only the rows that has end date today. But in my case my end date is a DateTime Column.

I tried the below code

DataView dvFormula = dsFormula.Tables[0].DefaultView;
dvFormula.RowFilter = "date(EndDateTime)='" + startDate.ToString("yyyyMMdd") + "'";
dvFormula.Sort = "FromDateTime ASC";

But date(EndDateTime) is not working.

尝试与LIKE比较,它比较EndDateTime的一部分是否等于您的startDate。

dvFormula.RowFilter = "EndDateTime LIKE '*" + startDate.ToString("yyyyMMdd") + "*'";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM