Hello all
First off, love this forum.... has provided so much assistance for me in learning Access!
I am having trouble writing a query to calculate the number of days between certain events.
Currently i have a table set up that contains:
tblMove
Object
Start Date
Move Date
Status (can be either 'On Hire', 'Off Hire', or 'Returned')
Now, i want to be able to count the number of days between the start date and the move date when the status is changed to 'Off Hire' - which in below example 1 would be 9 days.
However, if there is no status change to 'Off Hire', then i want the result to display the days between the last record set and the start date, which in below example 2 would be 14 days
example 1
Object A......01/01/15......02/01/15......On Hire
Object A......01/01/15......06/01/15......On Hire
Object A......01/01/15......10/01/15......Off Hire
Object A......01/01/15......15/01/15......Returned
example 2
Object A......01/01/15......02/01/15......On Hire
Object A......01/01/15......06/01/15......On Hire
Object A......01/01/15......10/01/15......On Hire
Object A......01/01/15......15/01/15......Returned
Or, to put it in simpler terms..... i want the query to run through the results and return the number of days when it hits the first recordset with 'Off Hire' status, otherwise, return the the number of days from the last recordset in the query.
Hopefully someone understands what i am trying to do and can give me some advice.
Regards
Zuzu
First off, love this forum.... has provided so much assistance for me in learning Access!
I am having trouble writing a query to calculate the number of days between certain events.
Currently i have a table set up that contains:
tblMove
Object
Start Date
Move Date
Status (can be either 'On Hire', 'Off Hire', or 'Returned')
Now, i want to be able to count the number of days between the start date and the move date when the status is changed to 'Off Hire' - which in below example 1 would be 9 days.
However, if there is no status change to 'Off Hire', then i want the result to display the days between the last record set and the start date, which in below example 2 would be 14 days
example 1
Object A......01/01/15......02/01/15......On Hire
Object A......01/01/15......06/01/15......On Hire
Object A......01/01/15......10/01/15......Off Hire
Object A......01/01/15......15/01/15......Returned
example 2
Object A......01/01/15......02/01/15......On Hire
Object A......01/01/15......06/01/15......On Hire
Object A......01/01/15......10/01/15......On Hire
Object A......01/01/15......15/01/15......Returned
Or, to put it in simpler terms..... i want the query to run through the results and return the number of days when it hits the first recordset with 'Off Hire' status, otherwise, return the the number of days from the last recordset in the query.
Hopefully someone understands what i am trying to do and can give me some advice.
Regards
Zuzu
Last edited: