Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. UTC Time Conversion

UTC Time Conversion

Scheduled Pinned Locked Moved C#
databasevisual-studiocomhelpquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    milo xml
    wrote on last edited by
    #1

    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?

    L R 2 Replies Last reply
    0
    • M milo xml

      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?

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      How are the dates stored in the database? NB: they should be stored as DateTime types, i.e. UTC.

      M 1 Reply Last reply
      0
      • M milo xml

        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?

        R Offline
        R Offline
        Richard Deeming
        wrote on last edited by
        #3

        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

        M 1 Reply Last reply
        0
        • L Lost User

          How are the dates stored in the database? NB: they should be stored as DateTime types, i.e. UTC.

          M Offline
          M Offline
          milo xml
          wrote on last edited by
          #4

          It's Access. So I'm assuming the worst.

          1 Reply Last reply
          0
          • R Richard Deeming

            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

            M Offline
            M Offline
            milo xml
            wrote on last edited by
            #5

            Luckily the application and the data will be on the same computer. I think that by using the second method, which is able to get the local timezone info and convert it to UTC, I'll be able to avoid that mess.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups