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. Database & SysAdmin
  3. Database
  4. Incorrect Time in DateTime column with MS Access database

Incorrect Time in DateTime column with MS Access database

Scheduled Pinned Locked Moved Database
helpcsharpdatabasevisual-studio
4 Posts 2 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.
  • S Offline
    S Offline
    Scott Page
    wrote on last edited by
    #1

    I have a table in an MS Access database with a Date/Time datatype for one of the fields. I generated a DataSet using a OledbDataAdapter in the VS.NET 2003 Forms Designer from the table mentioned previously. Everything works as expected during Fill and Updates. My problem is that the DateTime displays the Date portion correctly, but the Time is constantly 12:00:00 AM, not the time that was inserted. I recall seeing this problem a few years ago, but I have forgotten the solution and all of my searches come up empty. Any help would be greatly appreciated! Thanks, Scott

    "Some people spend an entire lifetime wondering if they made a difference. The Marines don't have that problem." ( President Ronald Reagan)

    S S 2 Replies Last reply
    0
    • S Scott Page

      I have a table in an MS Access database with a Date/Time datatype for one of the fields. I generated a DataSet using a OledbDataAdapter in the VS.NET 2003 Forms Designer from the table mentioned previously. Everything works as expected during Fill and Updates. My problem is that the DateTime displays the Date portion correctly, but the Time is constantly 12:00:00 AM, not the time that was inserted. I recall seeing this problem a few years ago, but I have forgotten the solution and all of my searches come up empty. Any help would be greatly appreciated! Thanks, Scott

      "Some people spend an entire lifetime wondering if they made a difference. The Marines don't have that problem." ( President Ronald Reagan)

      S Offline
      S Offline
      sam
      wrote on last edited by
      #2

      Please check your data insertion code you might be inserting only date not time.Ms-Access is showing it's default behaviour when you are trying to access date wiche is actually not present in the column or what it has inserted by it's own

      S 1 Reply Last reply
      0
      • S sam

        Please check your data insertion code you might be inserting only date not time.Ms-Access is showing it's default behaviour when you are trying to access date wiche is actually not present in the column or what it has inserted by it's own

        S Offline
        S Offline
        Scott Page
        wrote on last edited by
        #3

        The DataSet and INSERT statement where both created by the designer using a DateTime type for the column in code. The database is set to for Date/Time datatype. Even when I have tried to update it manually using SQL and oledb commands, the resulting query returns the same... Correct date, 12:00:00 AM time. There is a workaround somewhere, I've used it a few years back, but not recently enough to remeber what it was. In the mean time, I changed the field datatype in the database to Numeric - Double. In my code I add a column at runtime and convert the OADate (Double) to a .NET DateTime type and disply the DateTime.ToShortDateString in generated column, then map that to my ComboBox DisplayMember property. It works, but shouldn't be that way. Thanks for the help

        "Some people spend an entire lifetime wondering if they made a difference. The Marines don't have that problem." ( President Ronald Reagan)

        1 Reply Last reply
        0
        • S Scott Page

          I have a table in an MS Access database with a Date/Time datatype for one of the fields. I generated a DataSet using a OledbDataAdapter in the VS.NET 2003 Forms Designer from the table mentioned previously. Everything works as expected during Fill and Updates. My problem is that the DateTime displays the Date portion correctly, but the Time is constantly 12:00:00 AM, not the time that was inserted. I recall seeing this problem a few years ago, but I have forgotten the solution and all of my searches come up empty. Any help would be greatly appreciated! Thanks, Scott

          "Some people spend an entire lifetime wondering if they made a difference. The Marines don't have that problem." ( President Ronald Reagan)

          S Offline
          S Offline
          Scott Page
          wrote on last edited by
          #4

          Problem solved. Solution: Change all DataAdapter DateTime columns Input and Update parameters OleDbType to DBTimeStamp. By default the designer sets any Date/Time column to DBDate which only formats the data to store the date. This goes for DataAdapters created by the designer and for manually coded OleDbParameters.

          "Some people spend an entire lifetime wondering if they made a difference. The Marines don't have that problem." ( President Ronald Reagan)

          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