I've got a distributed app that is causing me trouble over time zones. I'm hoping someone can recommend what approach you should take to handle times using BOS. I realize this isn't necessarily specific to DevForce, but I can't seem to find anything elsewhere.
My architecture is SQL Server 2008R2, BOS and distributed WinForm/WPF apps. So the thick clients are running local to the user and therefore pick up their time zone information. I'm currently using DATE and SMALLDATETIME fields in SQL Server, so they are retrieved (stored) as local time relative to the server. Server is located in EST.
Here's what happens and some issues I'm having. Some to be expected - some I'm not sure of what the best practice is to handle.
If a user in CST enters a date to search on a DATE field in SQL Server, XML serialization picks it up and offsets it one hour so '2011-08-29' becomes '2011-08-29 01:00' when LINQ actually goes to query the database. SQL Server and LINQ in their wisdom decide it's ok for a query against a DATE field to include time and the query returns zero records. Is there a recommended way to handle this?
For date/time in general, should I be using the newer date offset data type in SQL Server to store date/time values? If a user enters a time in CST such as '2011-08-29 07:35', when it reaches the server, it becomes '2011-08-29 08:35' and then saves to the db as the last date/time. This is fine until one day our data center moves and is then located in CST. At that point, the db still shows the '08:35' time and XML serialization wouldn't change it back to '07:35'. None of the examples I see show using any other date/time data type, but could you offer your suggestion on how to handle this?
Lastly, all of this of course impacts reporting after the fact. So I'm trying to take all this into consideration on how I'm getting data out. We're currently using SSRS, which would run local to the server, so if the data doesn't stay relative to the time zone, it would appear to be off (a CST time converted to EST would look like it was off an hour).
What I would prefer to do (maybe not recommended) is keep everything relative to the time zone where data is entered. So if a CST entered time is '2011-08-29 07:35', that's how I'd like to store in the db because if someone in EST looks at a report for CST, they would want to see '07:35' (the time relative to CST in which something happened). This would also solve any reporting problems for our environment. Is there any way to get DevForce (or the XML serializer) to ignore the time zone offset?
Thanks for anyone's input and let me know if I can clarify further.
Scott