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. Visual Basic
  4. Date problem

Date problem

Scheduled Pinned Locked Moved Visual Basic
databasehelptutorial
6 Posts 5 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.
  • H Offline
    H Offline
    hang_em
    wrote on last edited by
    #1

    I have made this database which use ms-access and the data are enter through vb6. On the form the date entered were display as they are entered but on the access table is has changed for example 1 jan 2008, 25 jan, 2008 were display like 01-jan-08 and 25-jan-08 respectively which is okay, but 4 july 2008 happen to be 07-apr-08 and 12 oct 2008 becomes 10 dec 2008. Can any one tell me how some dates gets change in the .mdb file while some doesnot change, and even they are change in the ms-access database file when display them on the form they look still okay as enter. Would be grateful is anyone throw light on this. Thank you. SZ

    T D S B 4 Replies Last reply
    0
    • H hang_em

      I have made this database which use ms-access and the data are enter through vb6. On the form the date entered were display as they are entered but on the access table is has changed for example 1 jan 2008, 25 jan, 2008 were display like 01-jan-08 and 25-jan-08 respectively which is okay, but 4 july 2008 happen to be 07-apr-08 and 12 oct 2008 becomes 10 dec 2008. Can any one tell me how some dates gets change in the .mdb file while some doesnot change, and even they are change in the ms-access database file when display them on the form they look still okay as enter. Would be grateful is anyone throw light on this. Thank you. SZ

      T Offline
      T Offline
      TheComputerMan
      wrote on last edited by
      #2

      It is a long time since I used Access and VB6 but as I recall the dates in the mdb file are always in American format (mm-dd-yyyy). What I don't understand is how 28 Jan 08 remains untouched! Possibly the problem is that 28 Jan 08 does not have an American equivalent so is forced to what happens to be the correct format. You should set something up to specifically format your dates as you want to see them rather than depend on the built in stuff.

      1 Reply Last reply
      0
      • H hang_em

        I have made this database which use ms-access and the data are enter through vb6. On the form the date entered were display as they are entered but on the access table is has changed for example 1 jan 2008, 25 jan, 2008 were display like 01-jan-08 and 25-jan-08 respectively which is okay, but 4 july 2008 happen to be 07-apr-08 and 12 oct 2008 becomes 10 dec 2008. Can any one tell me how some dates gets change in the .mdb file while some doesnot change, and even they are change in the ms-access database file when display them on the form they look still okay as enter. Would be grateful is anyone throw light on this. Thank you. SZ

        D Offline
        D Offline
        Dave Kreskowiak
        wrote on last edited by
        #3

        Internally, the dates are not stored in any format. They are a serial number that represents a date/time. The problem appears to be that whatever code is entering dates into the database is using methods that are no culture-tolerant nor consistant acrossed the code. The common mistake that causes this is using string concatentation to build SQL queries using dates:

        ' The BAD way...
        Dim query As String
        query = "INSERT INTO table VALUES (#" & somedatevariable & "#)"
        

        You should be using parameterized queries instead. Use the OleDbParameter class to handle dates and times for you. You can find a good example of this here[^].

        A guide to posting questions on CodeProject[^]
        Dave Kreskowiak

        1 Reply Last reply
        0
        • H hang_em

          I have made this database which use ms-access and the data are enter through vb6. On the form the date entered were display as they are entered but on the access table is has changed for example 1 jan 2008, 25 jan, 2008 were display like 01-jan-08 and 25-jan-08 respectively which is okay, but 4 july 2008 happen to be 07-apr-08 and 12 oct 2008 becomes 10 dec 2008. Can any one tell me how some dates gets change in the .mdb file while some doesnot change, and even they are change in the ms-access database file when display them on the form they look still okay as enter. Would be grateful is anyone throw light on this. Thank you. SZ

          S Offline
          S Offline
          sripchowdhury
          wrote on last edited by
          #4

          Hi Dear, Check your System's Date and Time Settings and make it DD-MM-YYYY, similarly at the time of save date into the access table use the format function like format(dtpicker1.value,"dd-mm-yyyy"). May this helps you...

          1 Reply Last reply
          0
          • H hang_em

            I have made this database which use ms-access and the data are enter through vb6. On the form the date entered were display as they are entered but on the access table is has changed for example 1 jan 2008, 25 jan, 2008 were display like 01-jan-08 and 25-jan-08 respectively which is okay, but 4 july 2008 happen to be 07-apr-08 and 12 oct 2008 becomes 10 dec 2008. Can any one tell me how some dates gets change in the .mdb file while some doesnot change, and even they are change in the ms-access database file when display them on the form they look still okay as enter. Would be grateful is anyone throw light on this. Thank you. SZ

            B Offline
            B Offline
            Bernhard Hiller
            wrote on last edited by
            #5

            Access interprets a date string in American format first. When that fails, it takes a look at the date settings of your computer, and tries again with those settings (or the other way round - I am not sure). Hence, on a non-American computer the outcome is sometimes correct, sometimes wrong. Parameterized queries - as suggested above - are the solution.

            H 1 Reply Last reply
            0
            • B Bernhard Hiller

              Access interprets a date string in American format first. When that fails, it takes a look at the date settings of your computer, and tries again with those settings (or the other way round - I am not sure). Hence, on a non-American computer the outcome is sometimes correct, sometimes wrong. Parameterized queries - as suggested above - are the solution.

              H Offline
              H Offline
              hang_em
              wrote on last edited by
              #6

              I got em right now, i had not set right on the form properties, makes changes there and hope it would work fine now. Thank you guys for your time. zela.

              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