Database does not take time value

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • J M

    #1

    Database does not take time value

    Hi,

    I have a huge problem in an app I'm writing.
    I use an OleDbDataset (and OleDbDataTable, and so on, created in the
    Component Designer) to add rows to a table.
    Three of the columns have Date/Time values.
    Column 1 is only a date (time: 0:00), no problem there.
    Columns 2&3 are only time (I struggled to extract only the time from a Date,
    who the hell came up with the idea of returning the TimeOfDay prop of a
    DateTime as a TimeSpan instead of a Date??)

    Here comes the problem: In my DataRow object, all data is correct (checked
    in QuickWatch), but in my database, the time columns are set to January 1,
    2001 0:00.
    I tried (among lots of other things, to test if I was doing something wrong)
    to pass the literal #5/10/2004 15:32# in one of the columns. in the database
    it showed as 5/10/2004 0:00...

    When reading dates from existing (that is, data that was already in the
    database before, entered in Access), there seems to be no problem....



    J Mous


  • Cor Ligthert

    #2
    Re: Database does not take time value

    Hi JM,

    A well known item, there is no time value in a database.
    So you would use a string or a datatime field where you know that you have
    to cut of the date.

    I hope this helps anyway?

    Cor


    Comment

    • J M

      #3
      Re: Database does not take time value

      But why then can it read values correctly, but not write them?
      Is it a bug in the framework??

      J Mous

      "Cor Ligthert" <notfirstname@p lanet.nl> wrote in message
      news:%23snRXVsT EHA.1368@TK2MSF TNGP11.phx.gbl. ..[color=blue]
      > Hi JM,
      >
      > A well known item, there is no time value in a database.
      > So you would use a string or a datatime field where you know that you have
      > to cut of the date.
      >
      > I hope this helps anyway?
      >
      > Cor
      >
      >[/color]


      Comment

      • Cor Ligthert

        #4
        Re: Database does not take time value

        Hi JM,

        You can write them, however it will always be with the date 1900 01 01 (or
        something)

        Cor


        Comment

        • J M

          #5
          Re: Database does not take time value

          I found out a way to do it. Thanks for your help!!!
          I'll share it with you so if anyone encounters the same problem (quite
          likely): This is the solution:

          I changed the OleDbType for all date/time columns in the dataset designer to
          'time' (instead of dateTime) and in all parameters of all commands that had
          to do with the date/time values, I set OleDbType to "Date" instead of
          "DBDate"... I don't know which of the two did te job (or both)...

          J Mous

          (I'm sorry for spelling mistakes. 1/ English is not my primary language. 2/
          my H key seems to refuse to do anything most of the time...)


          "Cor Ligthert" <notfirstname@p lanet.nl> schreef in bericht
          news:eKrg8KtTEH A.3336@TK2MSFTN GP10.phx.gbl...[color=blue]
          > Hi JM,
          >
          > You can write them, however it will always be with the date 1900 01 01 (or
          > something)
          >
          > Cor
          >
          >[/color]


          Comment

          Working...