I am stuck. Help is needed.
I store UTC dates in a database.
Examples of lines:
GeneratedAt:
- 2011-06-08 23:30
- 2011-06-09 03:30
- 2011-06-09 15:30
The local time for my user is -2 hours (Central Europe). When I need lines from 09, I have 3 lines.
The problem is related to GROUP BY for reporting purposes. I have 1 for 08 and 2 for 09, but this does not match my local time.
Everywhere I see: "store data in UTC format." How to do it right?
UPDATE 1:
I use NHibernate to access the data, and I prefer the solution regardless of the database engine. So I'm looking for a solution with something like a Date / Time Dimension table (or something like that).
My data table has these columns:
- GeneratedAt (datetime)
- GeneratedAt_Year (int)
- GeneratedAt_Month (int)
- GeneratedAt_Day (int)
- GeneratedAt_Hour (int)
Thanks to this, I can easily group: year, year + month, year + month + day, year + month + day + hour. Unfortunately, this is UTC. :(
How to reorganize this solution to handle custom time zones?
source share