View Single Post
  #9  
Old April 10th, 2010, 06:17 AM posted to microsoft.public.access.gettingstarted
Seano
external usenet poster
 
Posts: 10
Default How to show time for day's stock market high/low

Many thanks, John. I managed to get this working, and I feel closer to the
answer, but alas it returns the Max(High) for every minute in the database,
not the highest High for the day. I'm after the highest High in every 24-hour
period and the Time (minute) that occurred. Apologies for not explaining it
properly (see my reply to Karl Dewey for further clarification).

"John Spencer" wrote:

To get the date and time and the high you can use a correlated sub-query.
SELECT [Date], [Time], [High]
FROM [SomeTable]
WHERE [High] =
(SELECT Max(High)
FROM [SomeTable] as T
WHERE T.[Date]=[SomeTable].[Date])

You would need s similar query to get the lows
SELECT [Date], [Time], [Low]
FROM [SomeTable]
WHERE [Low] =
(SELECT Min([Low])
FROM [SomeTable] as T
WHERE T.[Date]=[SomeTable].[Date])

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

Seano wrote:
Thanks John, the fieldnames are date/time/open/high/low/close/volume for each
minute of the day. Date and time originally came as one field but I separated
them (I could join them again if needed). So I guess I'm looking for the Max
of the high field for the day, and the minute it occurred, and the Min of the
low field, and the minute it occurred.

"John W. Vinson" wrote:

On Thu, 8 Apr 2010 18:20:01 -0700, Seano
wrote:

I've set up a database of stock market intraday data going back two years,
showing Open/High/Low/Close data for every one minute bar of the day. I'm
trying to find 1) the high and low of each day, and 2) the times they
occurred.

Using: Date By Day: Format$([Stock Data].[Date],'yyyy.mm.dd') I can find the
Max of High and Min of Low to give me the day's high and low, but how do I
find the minute these occurred (there may be more than one, so if only one
could be displayed, the first occurence would be best ).

Many thanks

The Format function isn't necessary (or even a very good way to do this): the
DateValue() function will extract just the date portion for grouping. To get
the high for the day and its time you can use a subquery. Could you post the
actual fieldnames of your table, and indicate which field contains the price
of interest? Is there in fact a high/low/open/close field for each *minute*?
And does the field (misnamed, it's a reserved word) Date contain the date and
time?

--

John W. Vinson [MVP]
.

.