tags:

views:

35

answers:

3

I have a winform client and wcf service that together display historical data. the data stored in the db with utc timestamps. If two clients in different time zones want to look at a most recent day's worth of data based on their local time, can it be possible that they would be looking at different sets of data?

+2  A: 

That depends.

  1. If "a day's worth" means "the last 24 hours", then they will both see the same data.
  2. If "a day's worth" means "00:00-23:59 of (current date - 1) in the user's local time zone", then they might see different data.

Example:

      event 1      event 2       +---- service request
         |            |          v

|---------------|---------------|-  days in Central Europe

--------|-----------------|-------  days in the US (Pacific time)

---------------|---------------|--  UTC day boundaries

In case 1, you just go back 24 hours from the time of the service request. It's easy to see that both customers, the one in the US and the one in Europe, will get the same list of events.

In case 2, it's more difficult: With respect to US time, events 1 and 2 happen on the same day. With respect to Europe, both events happen on different days, so the results will be different for the client in the US and the client in Europe.

Heinzi
Hi Heinzi, could you explain more what is the difference between the 2 cases?
@user428468: Edited my answer.
Heinzi
hmm That makes it much more clear. So from your explanation, it looks like I want to implement the 2nd case, which will make it difficult for the same reason you just said. In that case I will need to notify the user that even though he/she may be looking for 1 day's data in their local time, there is some fresher data available on the db. Is that a good solution?
+1  A: 

Without further details the answer is both.

  1. If a day is defined in the local time zone then changed to the UTC format before the request to the db is made they will have different data sets.

  2. if the query is somthing like

    select * from dbTable where TimeStamp >= '9/22/2010' and TimeStamp < '9/23/2010' 
    

    or

    select * from dbTable where TimeStamp >= GetDate() - '24:00:00' and TimeStamp < GetDate() 
    

    then they will return the same set of data for both time zones.

Scott Chamberlain
A: 

It is certainly possible - it is one of the common issues with globalization/localization. The important thing to do is to convert all requests to UTC time before making the query. If the queries are all UTC-based, then the data returned to the local machines should match, as the UTC times will match.

Wonko the Sane