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. CRecordset-related question

CRecordset-related question

Scheduled Pinned Locked Moved C / C++ / MFC
questiondatabasehelp
3 Posts 2 Posters 2 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.
  • C Offline
    C Offline
    Christos P
    wrote on last edited by
    #1

    Hi all, I am using a Crecordset class to retrieve rows from an access database table. I am constructing the WHERE statement at runtime and pass it to CRecordset using m_strFilter. The problem is the following: I need to query a date field in the database (rem_date) based on a date provided by the user (m_date). I am using the following code (v_filter is the where statement): v_filter+="(rem_date="; v_filter+="{d'"; v_filter+=m_date.Format("%Y-%m-%d");:confused: v_filter+="'}"; v_filter+=" )"; The problem is that the above statement returns TRUE only when both the date and the (hidden) time is the same. I only need to compare the date portion. Do you know how can I do this? I thank yuo in advance, Christos P.

    R 1 Reply Last reply
    0
    • C Christos P

      Hi all, I am using a Crecordset class to retrieve rows from an access database table. I am constructing the WHERE statement at runtime and pass it to CRecordset using m_strFilter. The problem is the following: I need to query a date field in the database (rem_date) based on a date provided by the user (m_date). I am using the following code (v_filter is the where statement): v_filter+="(rem_date="; v_filter+="{d'"; v_filter+=m_date.Format("%Y-%m-%d");:confused: v_filter+="'}"; v_filter+=" )"; The problem is that the above statement returns TRUE only when both the date and the (hidden) time is the same. I only need to compare the date portion. Do you know how can I do this? I thank yuo in advance, Christos P.

      R Offline
      R Offline
      Ranjan Banerji
      wrote on last edited by
      #2

      Do not exactly remember the function that will get you parts of the date in Access but you need to do something like: Where DatePart( date_field, "mm-dd-yy") = DatePart( userDate, "mm-dd-yy" ) Try writing the query in Access it self first. Once you have it working you can can move it to your code by replacing the UserDate with the appropriate variable in your code.

      C 1 Reply Last reply
      0
      • R Ranjan Banerji

        Do not exactly remember the function that will get you parts of the date in Access but you need to do something like: Where DatePart( date_field, "mm-dd-yy") = DatePart( userDate, "mm-dd-yy" ) Try writing the query in Access it self first. Once you have it working you can can move it to your code by replacing the UserDate with the appropriate variable in your code.

        C Offline
        C Offline
        Christos P
        wrote on last edited by
        #3

        Dear Ranjan BANERJI, I would like to thank you for your reply but I feel that I have to exemplify my problem a bit more: I am able to extract the date portion from the user-supplied date but I am not able to do the same for the date retrieved from the database. What I need is the name of the SQL function that does this. Thank you for your time, Christos P.:)

        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