Skip to main content
Participating Frequently
June 12, 2006
Question

Between query with dates & access

  • June 12, 2006
  • 2 replies
  • 265 views
I am trying to create a results page that will show records between 2 dates from an access database. Without the dates the query works fine, but I am getting "Data Mismatch" error on this section of the code. I have read the information on date formats for access and have the table set to American format dates, but it is still not working. Any suggestions greatly appreciated.

SELECT Working_date, Start_Hour, Start_Mins, End_hour, End_Mins, Workings_Hours, Employee_Name
FROM Working_Hours
WHERE Employee_Name = 'MMColParam' AND Absence_Reason = 'MMColParam2'AND Working_date BETWEEN '#MMColParam3#' AND '#MMColParam4#'

Thanks,

Chris.
This topic has been closed for replies.

2 replies

Participating Frequently
June 14, 2006
Thanks for the help,

I have removed the ' from around the dates, but this then does the query without looking at the date at all - i.e. returns all items that match the first 2 criteria.

Any other suggestions please

Thanks
Inspiring
June 12, 2006
That's because you're passing strings.

'#1/1/2006#' == the string #1/1/2006#, which is incorrect.
#1/1/2006# == the date Jan 1, 2006, which is correct.

"Chris Morgan" <webforumsuser@macromedia.com> wrote in message
news:e6js0r$15c$1@forums.macromedia.com...
>I am trying to create a results page that will show records between 2 dates
> from an access database. Without the dates the query works fine, but I am
> getting "Data Mismatch" error on this section of the code. I have read the
> information on date formats for access and have the table set to American
> format dates, but it is still not working. Any suggestions greatly
> appreciated.
>
> SELECT Working_date, Start_Hour, Start_Mins, End_hour, End_Mins,
> Workings_Hours, Employee_Name
> FROM Working_Hours
> WHERE Employee_Name = 'MMColParam' AND Absence_Reason = 'MMColParam2'AND
> Working_date BETWEEN '#MMColParam3#' AND '#MMColParam4#'
>
> Thanks,
>
> Chris.
>