Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7792947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:19:55+00:00 2026-06-01T22:19:55+00:00

i’m having an issue comparing a date in an access database. basically i’m parsing

  • 0

i’m having an issue comparing a date in an access database. basically i’m parsing out a date from a text field, then trying to compare that date to another to only pull newer/older records.

so far i have everything working, but when i try to add the expression to the where clause, it’s acting like it’s not a date value.

here’s the full SQL:

SELECT 
Switch(Isdate(TRIM(LEFT(bc_testingtickets.notes, Instr(bc_testingtickets.notes, ' ')))) = false, 'NOT     ASSIGNED!!!') AS [Assigned Status],
TRIM(LEFT(bc_testingtickets.notes, Instr(bc_testingtickets.notes, ' '))) AS [Last Updated Date], 
bc_testingtickets.notes AS [Work Diary], 
bc_testingtickets.ticket_id, 
clients.client_code, 
bc_profilemain.SYSTEM, 
list_picklists.TEXT, 
list_picklists_1.TEXT, 
list_picklists_2.TEXT, 
list_picklists_3.TEXT, 
bc_testingtickets.createdate, 
bc_testingtickets.completedate, 
Datevalue(TRIM(LEFT([bc_TestingTickets].[notes], Instr([bc_TestingTickets].[notes], ' '))))  AS datetest 

FROM   list_picklists AS list_picklists_3 
 RIGHT JOIN (list_picklists AS list_picklists_2 
             RIGHT JOIN (list_picklists AS list_picklists_1 
                         RIGHT JOIN (bc_profilemain 
                                     RIGHT JOIN (((bc_testingtickets 
                                                   LEFT JOIN clients 
                                                     ON 
 bc_testingtickets.broker = clients.client_id) 
              LEFT JOIN list_picklists 
                ON 
 bc_testingtickets.status = list_picklists.id) 
             LEFT JOIN bc_profile2ticketmapping 
               ON bc_testingtickets.ticket_id = 
                  bc_profile2ticketmapping.ticket_id) 
   ON bc_profilemain.id = 
      bc_profile2ticketmapping.profile_id) 
 ON list_picklists_1.id = bc_testingtickets.purpose) 
 ON list_picklists_2.id = bc_profilemain.destination) 
   ON list_picklists_3.id = bc_profilemain.security_type 
WHERE  ( ( ( list_picklists.TEXT ) <> 'Passed' 
     AND ( list_picklists.TEXT ) <> 'Failed' 
     AND ( list_picklists.TEXT ) <> 'Rejected' ) 
   AND ( ( bc_testingtickets.ticket_id ) <> 4386 ) ) 
GROUP  BY bc_testingtickets.notes, 
    bc_testingtickets.ticket_id, 
    clients.client_code, 
    bc_profilemain.SYSTEM, 
    list_picklists.TEXT, 
    list_picklists_1.TEXT, 
    list_picklists_2.TEXT, 
    list_picklists_3.TEXT, 
    bc_testingtickets.createdate, 
    bc_testingtickets.completedate, 
    DateValue(TRIM(LEFT([bc_TestingTickets].[notes], Instr([bc_TestingTickets].[notes], ' ')))) 
ORDER  BY Datevalue(TRIM(LEFT([bc_TestingTickets].[notes], Instr([bc_TestingTickets].[notes], ' ')))); 

the value i’m trying to compare against a various date is this:

DateValue(Trim(Left([bc_TestingTickets].[notes],InStr([bc_TestingTickets].[notes],' '))))

if i add a section to the where clause like below, i get the Data Type Mismatch error:

WHERE DateValue(Trim(Left([bc_TestingTickets].[notes],InStr([bc_TestingTickets].[notes],' ')))) > #4/1/2012#

i’ve even tried using the DateValue function around the manual date i’m testing with but i still get the mismatch error:

WHERE DateValue(Trim(Left([bc_TestingTickets].[notes],InStr([bc_TestingTickets].[notes],' ')))) > DateValue("4/1/2012")

any tips on how i can compare a date in this method? i can’t change any fields in the database, ect, that’s why i’m parsing the date in SQL and trying to manipulate it so i can run reports against it.

i’ve tried googling but nothing specifically talks about parsing a date from text and converting it to a date object. i think it may be a bug or the way the date is being returned from the left/trim functions. you can see i’ve added a column to the end of the SELECT statement called DateTest and it’s obvious access is treating it like a date (when the query is run, it asks to sort by oldest to newest/newest to oldest instead of A-Z or Z-A), unlike the second column in the select.

thanks in advance for any tips/clues on how i can query based on the date.

edit:
i just tried the following statements in my where clause and still getting a mismatch:

CDate(Trim(Left([bc_TestingTickets].[notes],InStr([bc_TestingTickets].[notes],' ')))) > #4/1/2012#
CDate(Trim(Left([bc_TestingTickets].[notes],InStr([bc_TestingTickets].[notes],' ')))) >
CDate("4/1/2012") CDate(DateValue(Trim(Left([bc_TestingTickets].[notes],InStr([bc_TestingTickets].[‌​notes],' '))))) > #4/1/2012# 

i tried with all the various combinations i could think of regarding putting CDate inside of DateValue, outside, ect. the CDate function does look like what i should be using though. not sure why it’s still throwing the error.

here’s a link to a screenshot showing the results of the query http://ramonecung.com/access.jpg. there’s two screenshots in one image.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T22:19:56+00:00Added an answer on June 1, 2026 at 10:19 pm

    You reported you get Data Type Mismatch error with this WHERE clause.

    WHERE DateValue(Trim(Left([bc_TestingTickets].[notes],
        InStr([bc_TestingTickets].[notes],' ')))) > #4/1/2012#
    

    That makes me wonder whether [bc_TestingTickets].[notes] can ever be Null, either because the table design allows Null for that field, or Nulls are prohibited by the design but are present in the query’s set of candidate rows as the result of a LEFT or RIGHT JOIN.

    If Nulls are present, your situation may be similar to this simple query which also triggers the data type mismatch error:

    SELECT DateValue(Trim(Left(Null,InStr(Null,' '))));
    

    If that proves to be the cause of your problem, you will have to design around it somehow. I can’t offer a suggestion about how you should do that. Trying to analyze your query scared me away. 🙁

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
Basically, what I'm trying to create is a page of div tags, each has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I have a reasonable size flat file database of text documents mostly saved in
I have a bunch of posts stored in text files formatted in yaml/textile (from
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.