I want to store a a c# DateTimeOffset value in a SQL Server 2005 database.
Sql 2008 has this as a built-in-type, but SQL Server 2005 does not.
The DateTimeOffset structure has a DateTime value which I store as DateTime, an an Offset property (of type TimeSpan). Since this is the time zone relative to UTC, presumably it is usually at a whole number of hours or half-hours.
Suggestions on how best to store this in a SQL Server 2005 database?
It’s not a good idea to assume that an offset is a number of hours or half-hours – there are certainly quarter-hour timezones around.
Using milliseconds for the offset is probably the most flexible, but I’d argue that minutes is a lot easier to read. If you’re ever going to look at the ‘raw’ data in the database, it’s easier to understand value 60 = 1 hour than 3600000. I can’t imagine you really needing fractions of minutes as the offset.