Hi, I currently have a spreadsheet that pulls data from an SQL Database. The spreadsheet displays the top (Most recent) 24 records from the DB whenever it is refreshed. As this DB is an hourly data log, the spreadsheet is simply a 24hr display of historical data - with some charts that populate based on the data returned.

I'd like to improve this - but don't know how to... The SQL query is in a cell located in a different sheet of the workbook, so I can alter the query and see the results appear. What I would l like to do is be able to specify the year, month, date and hour to get the 24hr report starting at the hour specified. There is already a column for each of these parameters in the DB Table I just have not been able to put together a query that will pick the row I want plus the 23 that come after it. If I just wanted the 24 hrs from midnight day 1 to midnight day 2 it would be straightforward, but because it (could) span across the midnight rollover point I am struggling.

I should also mention that there is an index column that increments each time a row is added to the DB as I've a feeling this could be the key...