I want to know exactly what is the correct way to handle date as parameter in querying the db. My database is hosted in Windows Azure, and I have a table Job
which as a field Modified
with a DateTime
data type. The DateTime
is stored in the database as UTC.
I want to query the list of jobs based on the Modified
date. The user will enter a start and end date, but they are based in different time zones. How do I handle the dates to match exactly the data when querying the database?
I'm using ASP.Net MVC. I also need to ensure that daylight saving time is considered.
I know I cannot just simply write a query like:
var data = _context.Jobs
.Where(c => c.Modified >= startDate && c.Modified <= endDate);