dan henderson
asked on
use linq to get a record between two times
I have a record in sql server 2016 that has two time(0) columns. I need to do a query with linq that returns the id when the current time is between the 2 stored times (starttime and endtime).
any help appreciated.
any help appreciated.
string now = DateTime.Now.ToString("HH:mm:ss");
var result = (from s in db.Shifts
where s.StartTime >= DateTime.Parse(now) &&
s.EndTime <= DateTime.Parse(now)
select s.ShiftId);
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
do any shift cross-over midnight?
Can you provide sample data?