Results 1 to 4 of 4
  1. #1
    bobt_1234 is offline Novice
    Windows XP Access 2007
    Join Date
    Feb 2012
    Posts
    6

    Data type mismatch in criteria expression

    I get this error message when I try to "order by" a column of dates that has mostly valid dates, but contains some invalid dates

    select * from gnames order by format(cdate(dob),'yyyymmdd')

    DOB might have values like:
    1/1/1964
    3/5/1982


    about 1971
    ?

    Is there a way to order by this date column, but throw out the bad dates without the query dying with that error message? Or trap the error in the query statement so that it displays only the good date values?

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    You can try adding a criteria to the query:

    SELECT...
    FROM...
    WHERE IsDate(DOB)
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    bobt_1234 is offline Novice
    Windows XP Access 2007
    Join Date
    Feb 2012
    Posts
    6
    Cool! That worked.

    Thanks.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Happy to help, and welcome to the site by the way!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Data Type mismatch in criteria expression
    By elb1999 in forum Queries
    Replies: 2
    Last Post: 01-20-2012, 02:38 PM
  2. Data type mismatch in criteria expression
    By buienxg in forum Access
    Replies: 2
    Last Post: 11-22-2011, 10:29 AM
  3. Data type mismatch in criteria expression
    By Douglasrac in forum Forms
    Replies: 3
    Last Post: 11-23-2010, 10:46 AM
  4. data type mismatch in criteria expression
    By broecher in forum Access
    Replies: 4
    Last Post: 09-10-2010, 08:29 AM
  5. Data type mismatch in criteria expression
    By shexe in forum Queries
    Replies: 2
    Last Post: 09-01-2010, 12:47 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums