Query ignores date parameters - works when hardcoded but not as cell reference.

9tanstaafl9

Well-known Member
Joined
Mar 23, 2008
Messages
535
Please help, or I'm going to have a bald spot (bad for girls)! The following query works fine if I substitute actual dates for the parameters, but if I try to enter dates into fields on the spreadsheet and reference those fields in the query instead, the query completely ignores the dates and returns only the rows that happened to have had null dates.

Using Microsoft Query Editor to query Visual Foxpro tables.

So this returns the null dates:

Code:
SELECT 'COR' as Type, prmchg.recnum, prmchg.jobnum, prmchg.chgdte as Creation
FROM prmchg prmchg
WHERE prmchg.status = $1 AND prmchg.chgdte >={?CO1} AND prmchg.chgdte<={?CO2}UNION ALL
 
SELECT 'JOB', actrec.recnum, actrec.recnum, actrec.biddte
FROM actrec actrec
WHERE actrec.biddte>={?JOB1} AND actrec.biddte<={?JOB2}
=============

But this works fine and gives me real values:

Code:
SELECT 'COR' as Type, prmchg.recnum, prmchg.jobnum, prmchg.chgdte as Creation
FROM prmchg prmchg
WHERE prmchg.status = $1 AND prmchg.chgdte >={12/1/11} AND prmchg.chgdte<={12/31/12}
 
UNION ALL
 
SELECT 'JOB', actrec.recnum, actrec.recnum, actrec.biddte
FROM actrec actrec
WHERE actrec.biddte>={12/1/11} AND actrec.biddte<={12/31/12}
==================

The only possible hint I have is that I had to use French brackets to make it accept my code at all, I didn't have to use them last time, but last time I used query editor, which doesn't work in 2010, so i'm not sure if that has something to do with it - this is a very different query and I'm not very good at these.
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Thanks, but no cigar. I am seriously going insane. We did figure out from doing this that somehow the automatic calculation had been turned off, but again, that didn't solve the problem either.
 
Upvote 0
If you wanted to design Hell for nerds, this would be the way to do it. Just make things that look like they should work, but make them not work.
 
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,971
Members
452,371
Latest member
Frana

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top