asp.net - Correct way to handle date in querying db -


i want know correct way handle date parameter in querying db. database hosted in windows azure, , have table job field modified datetime data type. datetime stored in database utc.

i want query list of jobs based on modified date. user enter start , end date, based in different time zones. how handle dates match data when querying database?

i'm using asp.net mvc. need ensure daylight saving time considered.

i know cannot write query like:

var data = _context.jobs                    .where(c => c.modified >= startdate && c.modified <= enddate); 

this hard problem since user's browser might not report correct time or timezone, assuming can trust ...

... it's still hard problem since need convert time entered in local time zone utc , involves knowing not timezone's offset (which easy browser) actual timezone in can apply appropriate offset daylight savings or not datetime entered , not 'now'.

this link might determine browser's timezone , actual calculations based on timezones should @ jon skeet's noda time library.

most people punt on daylight savings time issue , use browser's timezone offset adjust entered datetime values , assume when querying old data don't care 1 hour error (or expand query 1 hour include regardless).


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -