UTC Time Conversion
-
So I'm working on scavenging data from a vendor supplied product that uses an Access DB as its method of data storage. Since it's Access and they know it's not really an efficient database, they do all kinds of weird things in handling their data. They delete anything over 3 days old and they don't use the ID field as you would expect. So what I'm looking to do is pull new values once a minute or so based upon the timestamp. The problem comes in with Daylight Savings and the time changes. So to work around this, I'm thinking of converting to UTC to do the comparison using one of these two methods: DateTime.ToUniversalTime Method (System)[^] TimeZoneInfo.ConvertTimeToUtc Method (DateTime, TimeZoneInfo) (System)[^] I'm worried that I'm going the overkill route though. Anyone have any thoughts?
-
So I'm working on scavenging data from a vendor supplied product that uses an Access DB as its method of data storage. Since it's Access and they know it's not really an efficient database, they do all kinds of weird things in handling their data. They delete anything over 3 days old and they don't use the ID field as you would expect. So what I'm looking to do is pull new values once a minute or so based upon the timestamp. The problem comes in with Daylight Savings and the time changes. So to work around this, I'm thinking of converting to UTC to do the comparison using one of these two methods: DateTime.ToUniversalTime Method (System)[^] TimeZoneInfo.ConvertTimeToUtc Method (DateTime, TimeZoneInfo) (System)[^] I'm worried that I'm going the overkill route though. Anyone have any thoughts?
-
So I'm working on scavenging data from a vendor supplied product that uses an Access DB as its method of data storage. Since it's Access and they know it's not really an efficient database, they do all kinds of weird things in handling their data. They delete anything over 3 days old and they don't use the ID field as you would expect. So what I'm looking to do is pull new values once a minute or so based upon the timestamp. The problem comes in with Daylight Savings and the time changes. So to work around this, I'm thinking of converting to UTC to do the comparison using one of these two methods: DateTime.ToUniversalTime Method (System)[^] TimeZoneInfo.ConvertTimeToUtc Method (DateTime, TimeZoneInfo) (System)[^] I'm worried that I'm going the overkill route though. Anyone have any thoughts?
My first thought would be: what time zone is used when the data is inserted or updated in the database? If it's the local time zone on the computer that's running the application, then you might struggle. There's no guarantee that they're all set to use the same time zone, or that their clocks are properly synchronized. And once the value is in the Access database, you've lost all time zone information. If all the computers are in a domain - and all in the same time zone - you might be able to use Group Policy to manage the time zone: windows - Setting time zones with site-based Group Policy - Super User[^] Domain-joined computers will probably be set to synchronize their clocks with the domain controller, so you should be OK.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
How are the dates stored in the database? NB: they should be stored as DateTime types, i.e. UTC.
-
My first thought would be: what time zone is used when the data is inserted or updated in the database? If it's the local time zone on the computer that's running the application, then you might struggle. There's no guarantee that they're all set to use the same time zone, or that their clocks are properly synchronized. And once the value is in the Access database, you've lost all time zone information. If all the computers are in a domain - and all in the same time zone - you might be able to use Group Policy to manage the time zone: windows - Setting time zones with site-based Group Policy - Super User[^] Domain-joined computers will probably be set to synchronize their clocks with the domain controller, so you should be OK.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer