Best practices with saving datetime & timezone info in database when data is dependant on datetime

Hugo’s answer is mostly correct, but I’ll add a few key points: When you’re storing the customer’s time zone, do NOT store a numerical offset. As others have pointed out, the offset from UTC is only for a single point in time, and can easily change for DST and for other reasons. Instead, you should … Read more

How can I convert a Sql Server 2008 DateTimeOffset to a DateTime

Converting using almost any style will cause the datetime2 value to be converted to UTC. Also, conversion from datetime2 to datetimeoffset simply sets the offset at +00:00, per the below, so it is a quick way to convert from Datetimeoffset(offset!=0) to Datetimeoffset(+00:00) declare @createdon datetimeoffset set @createdon = ‘2008-12-19 17:30:09.1234567 +11:00’ select CONVERT(datetime2, @createdon, 1) … Read more

pandas out of bounds nanosecond timestamp after offset rollforward plus adding a month offset

Since pandas represents timestamps in nanosecond resolution, the timespan that can be represented using a 64-bit integer is limited to approximately 584 years pd.Timestamp.min Out[54]: Timestamp(‘1677-09-22 00:12:43.145225’) In [55]: pd.Timestamp.max Out[55]: Timestamp(‘2262-04-11 23:47:16.854775807’) And your value is out of this range 2262-05-01 00:00:00 and hence the outofbounds error Straight out of: https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#timestamp-limitations Workaround: This will … Read more

DateTime vs DateTimeOffset

DateTimeOffset is a representation of instantaneous time (also known as absolute time). By that, I mean a moment in time that is universal for everyone (not accounting for leap seconds, or the relativistic effects of time dilation). Another way to represent instantaneous time is with a DateTime where .Kind is DateTimeKind.Utc. This is distinct from … Read more