Searching criteria based on date/time

Posted on 2004-10-27
Last Modified: 2013-11-20
I am using access database (mdb). I have a Date/Time field in the database. My application allows user to enter start date and end date as searching criteria. How do I construct a sql query to do such search ? I am using ADO.

Question by:MyQ2004
    1 Comment
    LVL 2

    Accepted Solution


    Give something like this a shot:


    rs->Open("Select * from MyTable Where <date_field> between #<begin_date># and #<end_date>#", conn.GetInterfacePtr(), adOpenForwardOnly, adLockReadOnly, adCmdText);


    rs = Instance of _RecordsetPtr
    conn = Instance of _ConnectionPtr

    I hope that helps.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Suggested Solutions

    Title # Comments Views Activity
    Strange date stored 22 94
    iSeries FTP Exit Program 8 94
    Detect CR LF to each line 12 102
    notReplace  challenge 53 86
    Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
    Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
    This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
    This video Micro Tutorial is the first in a two-part series that shows how to create and use custom scanning profiles in Nuance's PaperPort 14.5 ( But the ability to create custom scanning profiles al…

    845 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    6 Experts available now in Live!

    Get 1:1 Help Now