Skip to main content
Announcements
Jan 15, Trends 2025! Get expert guidance to thrive post-AI with After AI: REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Data type mismatch in criteria expression

Hi,

When I am tring to reload access database table

CompanyItems:

LOAD ID,

    Name,

    Contact,

    Book,

    ItemType,

    Priority,

    Date;

SQL SELECT *

FROM CompanyItems

where Date between '01/07/2013' and '25/10/2013';

I am getting below error

Data type mismatch in criteria expression.

SQL SELECT *

FROM CompanyItems

where Date between '01/07/2013' and '25/10/2013'

Could anyone help me how to correct this.

1 Solution

Accepted Solutions
Not applicable
Author

Maeby you can try something like this:

CompanyItems:

LOAD ID,

    Name,

    Contact,

    Book,

    ItemType,

    Priority,

    Date;

SQL SELECT *

FROM CompanyItems

where Date between #01/07/2013# and #25/10/2013#;

View solution in original post

8 Replies
bbi_mba_76
Partner - Specialist
Partner - Specialist

Hi,

in access is working fine?

Not applicable
Author

Yes

Not applicable
Author

Hi,

Maeby you can use Date function over date values just to ensure the Database knows you are passing dates and not strings. This is ofcourse if the source data type is Date.

israrkhan
Specialist II
Specialist II

Hi,

Try This, Make sure Date is in same format.

CompanyItems:

LOAD ID,

    Name,

    Contact,

    Book,

    ItemType,

    Priority,

    Date;

SQL SELECT *

FROM CompanyItems

where Date between  TRY_CAST('01/07/2013' AS Date) and TRY_CAST('25/10/2013' AS Date);

Not applicable
Author

Thanks and sorry can you explain a bit more as I am not clear what it means.

Not applicable
Author

Thanks when I am using this it's showing below error

SQL##f - SqlState: 37000, ErrorCode: 4294964196, ErrorMsg: [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'Date between TRY_CAST('01/07/2013' AS Date) and TRY_CAST('25/10/2013' AS Date)'.

SQL SELECT *

FROM CompanyItems

where Date between TRY_CAST('01/07/2013' AS Date) and TRY_CAST('25/10/2013' AS Date)

Not applicable
Author

Maeby you can try something like this:

CompanyItems:

LOAD ID,

    Name,

    Contact,

    Book,

    ItemType,

    Priority,

    Date;

SQL SELECT *

FROM CompanyItems

where Date between #01/07/2013# and #25/10/2013#;

Not applicable
Author

You are right thanks it's working.