Query Between Starting Date & +10 days

ilcaa

Well-known Member
Joined
May 25, 2005
Messages
751
Office Version
  1. 365
Platform
  1. Windows
I have a Table, "Quotes", that is structured

qDate, qTicker, qHi
4/20/2015, goog, 540.93
4/19/2015, goog, 539.30
4/18/2015, goog, 537.10
....
3/19/2014, goog, 539.30
3/18/2014, goog, 537.10

I would like to run a query that returns the qHi of "goog" BETWEEN a given start date and 10 days forward.
I have, which gives me syntax error.

Code:
Select DistinctRow Max(Quotes.qHi)
From Quotes
Where ((Quotes.qTicker)= "goog" and
Where Quotes.qDate Between 2/10/2014 AND DateAdd("d", 2/10/2014, 10));

so it would return the MAX value of column qHi between 2/10/2014 and 2/20/2014.
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Try:
Code:
SELECT Max(Quotes.qHi)
FROM Quotes
WHERE (Quotes.qTicker="goog") 
AND (Quotes.qDate Between #2/10/2014# And DateAdd("d",#2/10/2014#,10));
 
Upvote 0
Hi Joe,

Thanks that DID work. But i found another issues with date + 10days. Since these are stock values the query includes weekend dates. What I really need is the Max value of next 10 Values from the Date provided. Here is an example, if i used 2/2/2015, and used DATES Max value would be 543.19 because it would include the weekend dates of 2/7 & 2/8. But I want the next 10 values, so 549.00 would be the answer.

Can you adjust the query for next 10 values after Start Date? Thanks for any help.

2/2/2015 533.00
2/3/2015 533.40
2/4/2015 532.67
2/5/2015 528.50
2/6/2015 537.20
2/9/2015 538.45

2/10/2015 540.20
2/11/2015 544.82
2/12/2015 543.19
2/13/2015 542.21
2/14/2015 549.00
 
Upvote 0
That changes the problem entirely and makes it much more difficult. Not sure how you would do that with somehow ranking the records, or sorting them and using recordsets and VBA.
 
Upvote 0
no that critical if its that much more complex, doesnt throw off point of the project.

thanks for the help
 
Upvote 0

Forum statistics

Threads
1,221,877
Messages
6,162,583
Members
451,776
Latest member
bosvinn

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