+ Reply to Thread
Results 1 to 4 of 4

Comparing Dates in Microsoft Query Criteria

  1. #1
    Registered User
    Join Date
    01-22-2009
    Location
    Madison, Wisconsin
    MS-Off Ver
    Excel 2003
    Posts
    4

    Comparing Dates in Microsoft Query Criteria

    I am importing data into Excel via an ODBC database. I want to pull data based on a date field in the record if it is less than the current date (Todays Date). The format of the date field in the database is ccyy-mm-dd (eg. 2009-01-22). If I put in a valid date (#01/21/2009#) in the Criteria field of Microsoft Query it works fine. When I put TODAY() or NOW() or =TODAY() or =NOW() it fails with "Syntax Error in Date". If I rearrange the database date with the MID and RIGHT functions inot mm/dd/yy and try the compare in the SQL ciew it still errors.
    Any help is much appreciated.

  2. #2
    Valued Forum Contributor
    Join Date
    08-26-2006
    Location
    -
    MS-Off Ver
    2010
    Posts
    388
    Try this code:
    Please Login or Register  to view this content.
    hth

  3. #3
    Registered User
    Join Date
    08-31-2020
    Location
    Adelaide
    MS-Off Ver
    2016
    Posts
    1

    Re: Comparing Dates in Microsoft Query Criteria

    tpcervelo
    I've used this for specifying how many days you want to include.
    Hope this helps.

    >=current_date()-62

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,895

    Re: Comparing Dates in Microsoft Query Criteria

    @LinsayPatterson

    The post you responded to is over 10 years old. I doubt anyone is still looking for a solution here. Please work on current threads.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1