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 / C++ / MFC
  4. retreive a date from a ADO database

retreive a date from a ADO database

Scheduled Pinned Locked Moved C / C++ / MFC
questiondatabase
7 Posts 4 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.
  • W Offline
    W Offline
    Willem B
    wrote on last edited by
    #1

    hi, i'm using ado to connect to my database. now i want to retreive a date from the _RecordsetPtr. how do i do this? I also want to do this with a Currency... my code: COleDateTime Date; Date = (????) pRecordset->Fields->GetItem("Date")->Value; []D [] []D []

    M J 2 Replies Last reply
    0
    • W Willem B

      hi, i'm using ado to connect to my database. now i want to retreive a date from the _RecordsetPtr. how do i do this? I also want to do this with a Currency... my code: COleDateTime Date; Date = (????) pRecordset->Fields->GetItem("Date")->Value; []D [] []D []

      M Offline
      M Offline
      Michael P Butler
      wrote on last edited by
      #2

      Personally, I use the function VariantTimeToSystemTime to convert the returned VARIANT_T into a SYSTEMTIME structure which can then be used by COleDateTime. Michael Wonder Woman, Wonder Woman. All the world's waiting for you, and the power you possess. In your satin tights, Fighting for your rights And the old Red, White and Blue.

      W 2 Replies Last reply
      0
      • M Michael P Butler

        Personally, I use the function VariantTimeToSystemTime to convert the returned VARIANT_T into a SYSTEMTIME structure which can then be used by COleDateTime. Michael Wonder Woman, Wonder Woman. All the world's waiting for you, and the power you possess. In your satin tights, Fighting for your rights And the old Red, White and Blue.

        W Offline
        W Offline
        Willem B
        wrote on last edited by
        #3

        this might sound stupid, but it doesn't seem to work... my code: _RecordsetPtr pRecordset; LPSYSTEMTIME time; VariantTimeToSystemTime((double)pRecordset->Fields->GetItem("Datum")->Value, time); :omg::omg::omg: It crashes.... []D [] []D []

        S 1 Reply Last reply
        0
        • W Willem B

          hi, i'm using ado to connect to my database. now i want to retreive a date from the _RecordsetPtr. how do i do this? I also want to do this with a Currency... my code: COleDateTime Date; Date = (????) pRecordset->Fields->GetItem("Date")->Value; []D [] []D []

          J Offline
          J Offline
          Joao Paulo Figueira
          wrote on last edited by
          #4

          You can build a COleDateTime from a _variant_t, the type that is returned from pRecordset->Fields->GetItem("Date")->Value. So, your code could look like:

          COleDateTime Date(pRecordset->Fields->GetItem("Date")->Value);

          W 1 Reply Last reply
          0
          • M Michael P Butler

            Personally, I use the function VariantTimeToSystemTime to convert the returned VARIANT_T into a SYSTEMTIME structure which can then be used by COleDateTime. Michael Wonder Woman, Wonder Woman. All the world's waiting for you, and the power you possess. In your satin tights, Fighting for your rights And the old Red, White and Blue.

            W Offline
            W Offline
            Willem B
            wrote on last edited by
            #5

            I got another solution: _RecordsetPtr pRecordset; COleDateTime date(pRecordset->Fields->GetItem("Datum")->Value); This works fine... Thanks for your help, Willem []D [] []D []

            1 Reply Last reply
            0
            • J Joao Paulo Figueira

              You can build a COleDateTime from a _variant_t, the type that is returned from pRecordset->Fields->GetItem("Date")->Value. So, your code could look like:

              COleDateTime Date(pRecordset->Fields->GetItem("Date")->Value);

              W Offline
              W Offline
              Willem B
              wrote on last edited by
              #6

              lol, i just found that solution, look at the previous post...:D thanks anyways... willem []D [] []D []

              1 Reply Last reply
              0
              • W Willem B

                this might sound stupid, but it doesn't seem to work... my code: _RecordsetPtr pRecordset; LPSYSTEMTIME time; VariantTimeToSystemTime((double)pRecordset->Fields->GetItem("Datum")->Value, time); :omg::omg::omg: It crashes.... []D [] []D []

                S Offline
                S Offline
                Steve S
                wrote on last edited by
                #7

                That will be because "time" points somewhere invalid/undefined. Try SYSTEMTIME time; VariantTimeToSystemTime((double)pRecordset->Fields->GetItem("Datum")->Value,&time); That will work, unless the date/time stored is NULL. Steve S [This signature space available for rent]

                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