How to compare only date components from DateTime in EF?

后端 未结 14 1030
野性不改
野性不改 2020-11-27 17:06

I am having two date values, one already stored in the database and the other selected by the user using DatePicker. The use case is to search for a particular date from the

14条回答
  •  没有蜡笔的小新
    2020-11-27 17:35

    //Note for Linq Users/Coders

    This should give you the exact comparison for checking if a date falls within range when working with input from a user - date picker for example:

    ((DateTime)ri.RequestX.DateSatisfied).Date >= startdate.Date &&
            ((DateTime)ri.RequestX.DateSatisfied).Date <= enddate.Date
    

    where startdate and enddate are values from a date picker.

提交回复
热议问题