Connecting Tech Pros Worldwide Forums | Help | Site Map

Date Query Problems

carverk@hotmail.com
Guest
 
Posts: n/a
#1: Jul 20 '05
Hello All

I'm in the middle of moving a MS Access DB to a MySql backend.
I have figured out about 90% of the problems I have faced, execpt
for this one.

I have 3 Queries, which pull records depending on a date range.
(Today,Last 7 Days,Next 7 Days) The one I'm having problems with
is the "Last 7 Days" Query.

Here's the Criteria I'm Using: Between Date() And DateAdd("d",-7,Date())

When the tables are in access things work Fine, but when the tables
are in MySql the Query doesn't work. Changing things a little and
playing around with the criteria, it looks like MySql/MyODBC or
something doesn't like the "-7" part, as when I make the # a non
negitive value the query works.

I have tried for the last 2 days changing the Criteria to work
but I can't seem to get it working. Can any of your wonderfull
people help?

PS: The "Next 7 Days" query is the same as above only removing the "-"

Barry
Guest
 
Posts: n/a
#2: Jul 20 '05

re: Date Query Problems


You need to use DATE_SUB(Date(), INTERVAL 7 DAY)


carverk@hotmail.com wrote:
[color=blue]
>Hello All
>
>I'm in the middle of moving a MS Access DB to a MySql backend.
>I have figured out about 90% of the problems I have faced, execpt
>for this one.
>
>I have 3 Queries, which pull records depending on a date range.
>(Today,Last 7 Days,Next 7 Days) The one I'm having problems with
>is the "Last 7 Days" Query.
>
>Here's the Criteria I'm Using: Between Date() And DateAdd("d",-7,Date())
>
>When the tables are in access things work Fine, but when the tables
>are in MySql the Query doesn't work. Changing things a little and
>playing around with the criteria, it looks like MySql/MyODBC or
>something doesn't like the "-7" part, as when I make the # a non
>negitive value the query works.
>
>I have tried for the last 2 days changing the Criteria to work
>but I can't seem to get it working. Can any of your wonderfull
>people help?
>
>PS: The "Next 7 Days" query is the same as above only removing the "-"
>
>[/color]

Barry
Guest
 
Posts: n/a
#3: Jul 20 '05

re: Date Query Problems


You need to use DATE_SUB(Date(), INTERVAL 7 DAY)


carverk@hotmail.com wrote:
[color=blue]
>Hello All
>
>I'm in the middle of moving a MS Access DB to a MySql backend.
>I have figured out about 90% of the problems I have faced, execpt
>for this one.
>
>I have 3 Queries, which pull records depending on a date range.
>(Today,Last 7 Days,Next 7 Days) The one I'm having problems with
>is the "Last 7 Days" Query.
>
>Here's the Criteria I'm Using: Between Date() And DateAdd("d",-7,Date())
>
>When the tables are in access things work Fine, but when the tables
>are in MySql the Query doesn't work. Changing things a little and
>playing around with the criteria, it looks like MySql/MyODBC or
>something doesn't like the "-7" part, as when I make the # a non
>negitive value the query works.
>
>I have tried for the last 2 days changing the Criteria to work
>but I can't seem to get it working. Can any of your wonderfull
>people help?
>
>PS: The "Next 7 Days" query is the same as above only removing the "-"
>
>[/color]

carverk@hotmail.com
Guest
 
Posts: n/a
#4: Jul 20 '05

re: Date Query Problems


Hello,

Thanks for the Info. However when I past this into the
Access Query Windows "Critera" field and try to run the
query I get "Undefined "DATE_SUB" In Expression".




Barry <barry@nospamppsolutions.co.uk> wrote in message news:<3FC3287A.8070202@nospamppsolutions.co.uk>...[color=blue]
> You need to use DATE_SUB(Date(), INTERVAL 7 DAY)
>
>
> carverk@hotmail.com wrote:
>[color=green]
> >Hello All
> >
> >I'm in the middle of moving a MS Access DB to a MySql backend.
> >I have figured out about 90% of the problems I have faced, execpt
> >for this one.
> >
> >I have 3 Queries, which pull records depending on a date range.
> >(Today,Last 7 Days,Next 7 Days) The one I'm having problems with
> >is the "Last 7 Days" Query.
> >
> >Here's the Criteria I'm Using: Between Date() And DateAdd("d",-7,Date())
> >
> >When the tables are in access things work Fine, but when the tables
> >are in MySql the Query doesn't work. Changing things a little and
> >playing around with the criteria, it looks like MySql/MyODBC or
> >something doesn't like the "-7" part, as when I make the # a non
> >negitive value the query works.
> >
> >I have tried for the last 2 days changing the Criteria to work
> >but I can't seem to get it working. Can any of your wonderfull
> >people help?
> >
> >PS: The "Next 7 Days" query is the same as above only removing the "-"
> >
> >[/color][/color]
carverk@hotmail.com
Guest
 
Posts: n/a
#5: Jul 20 '05

re: Date Query Problems


Hello,

Thanks for the Info. However when I past this into the
Access Query Windows "Critera" field and try to run the
query I get "Undefined "DATE_SUB" In Expression".




Barry <barry@nospamppsolutions.co.uk> wrote in message news:<3FC3287A.8070202@nospamppsolutions.co.uk>...[color=blue]
> You need to use DATE_SUB(Date(), INTERVAL 7 DAY)
>
>
> carverk@hotmail.com wrote:
>[color=green]
> >Hello All
> >
> >I'm in the middle of moving a MS Access DB to a MySql backend.
> >I have figured out about 90% of the problems I have faced, execpt
> >for this one.
> >
> >I have 3 Queries, which pull records depending on a date range.
> >(Today,Last 7 Days,Next 7 Days) The one I'm having problems with
> >is the "Last 7 Days" Query.
> >
> >Here's the Criteria I'm Using: Between Date() And DateAdd("d",-7,Date())
> >
> >When the tables are in access things work Fine, but when the tables
> >are in MySql the Query doesn't work. Changing things a little and
> >playing around with the criteria, it looks like MySql/MyODBC or
> >something doesn't like the "-7" part, as when I make the # a non
> >negitive value the query works.
> >
> >I have tried for the last 2 days changing the Criteria to work
> >but I can't seem to get it working. Can any of your wonderfull
> >people help?
> >
> >PS: The "Next 7 Days" query is the same as above only removing the "-"
> >
> >[/color][/color]
Barry
Guest
 
Posts: n/a
#6: Jul 20 '05

re: Date Query Problems


DATE_SUB is a function of MySQL so won't work in Access. I thought you
were moving from Access to MySQL so assumed you would need the MySQL
function.

carverk@hotmail.com wrote:
[color=blue]
>Hello,
>
>Thanks for the Info. However when I past this into the
>Access Query Windows "Critera" field and try to run the
>query I get "Undefined "DATE_SUB" In Expression".
>
>
>
>
>Barry <barry@nospamppsolutions.co.uk> wrote in message news:<3FC3287A.8070202@nospamppsolutions.co.uk>...
>
>[color=green]
>>You need to use DATE_SUB(Date(), INTERVAL 7 DAY)
>>
>>
>>carverk@hotmail.com wrote:
>>
>>
>>[color=darkred]
>>>Hello All
>>>
>>>I'm in the middle of moving a MS Access DB to a MySql backend.
>>>I have figured out about 90% of the problems I have faced, execpt
>>>for this one.
>>>
>>>I have 3 Queries, which pull records depending on a date range.
>>>(Today,Last 7 Days,Next 7 Days) The one I'm having problems with
>>>is the "Last 7 Days" Query.
>>>
>>>Here's the Criteria I'm Using: Between Date() And DateAdd("d",-7,Date())
>>>
>>>When the tables are in access things work Fine, but when the tables
>>>are in MySql the Query doesn't work. Changing things a little and
>>>playing around with the criteria, it looks like MySql/MyODBC or
>>>something doesn't like the "-7" part, as when I make the # a non
>>>negitive value the query works.
>>>
>>>I have tried for the last 2 days changing the Criteria to work
>>>but I can't seem to get it working. Can any of your wonderfull
>>>people help?
>>>
>>>PS: The "Next 7 Days" query is the same as above only removing the "-"
>>>
>>>
>>>
>>>[/color][/color][/color]

Barry
Guest
 
Posts: n/a
#7: Jul 20 '05

re: Date Query Problems


DATE_SUB is a function of MySQL so won't work in Access. I thought you
were moving from Access to MySQL so assumed you would need the MySQL
function.

carverk@hotmail.com wrote:
[color=blue]
>Hello,
>
>Thanks for the Info. However when I past this into the
>Access Query Windows "Critera" field and try to run the
>query I get "Undefined "DATE_SUB" In Expression".
>
>
>
>
>Barry <barry@nospamppsolutions.co.uk> wrote in message news:<3FC3287A.8070202@nospamppsolutions.co.uk>...
>
>[color=green]
>>You need to use DATE_SUB(Date(), INTERVAL 7 DAY)
>>
>>
>>carverk@hotmail.com wrote:
>>
>>
>>[color=darkred]
>>>Hello All
>>>
>>>I'm in the middle of moving a MS Access DB to a MySql backend.
>>>I have figured out about 90% of the problems I have faced, execpt
>>>for this one.
>>>
>>>I have 3 Queries, which pull records depending on a date range.
>>>(Today,Last 7 Days,Next 7 Days) The one I'm having problems with
>>>is the "Last 7 Days" Query.
>>>
>>>Here's the Criteria I'm Using: Between Date() And DateAdd("d",-7,Date())
>>>
>>>When the tables are in access things work Fine, but when the tables
>>>are in MySql the Query doesn't work. Changing things a little and
>>>playing around with the criteria, it looks like MySql/MyODBC or
>>>something doesn't like the "-7" part, as when I make the # a non
>>>negitive value the query works.
>>>
>>>I have tried for the last 2 days changing the Criteria to work
>>>but I can't seem to get it working. Can any of your wonderfull
>>>people help?
>>>
>>>PS: The "Next 7 Days" query is the same as above only removing the "-"
>>>
>>>
>>>
>>>[/color][/color][/color]

Closed Thread


Similar MySQL Database bytes