Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Generate a list of dates that occur between two date values on a form.

Status
Not open for further replies.

Artois27

Technical User
Nov 19, 2010
34
GB
Access 2007, how can I write a query that will return a list of days between two dates given on a form. E.g. given 21/03/2012 and 28/03/2012 it would generate a table with the values:
• 21/03/2012
• 22/03/2012
• 23/03/2012
• 24/03/2012
• 25/03/2012
• 26/03/2012
• 27/03/2012
• 28/03/2012
To further explain, I have a table with employee absences in. It has a start and end date for each absence. However, when I want to query who is off on any given date range, I’m unable to. Given an absence in a table start date 21/03/2012 and end date 28/03/2012. If I query who is off between 22/03/2012 and 24/03/2012 using values given on a form, an access query (to my knowledge) can’t return anything as none of those dates appear in the table. Can anyone help?
 
an access query (to my knowledge) can't return anything as none of those dates appear in the table
A starting point:
Code:
SELECT * FROM tblAbsences
WHERE [start absence] <= Forms![name of form]![name of END control]
  AND [end absence] >= Forms![name of form]![name of START control]

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top