Query Date Range

M

MRCUSA

Hi
I have a database for rentals, with an arrival date field and a departure
date field. It is easy to count the days between one and the other.
The question is, if an arrival date is Feb 23 and Departure March 15, from
the 20 days difference, I just want to count the days stayed this month,
March.
How can I write a query to return this please?
Thanks in advance!
MRC
 
R

Ron2006

Hi
I have a database for rentals, with an arrival date field and a departure
date field. It is easy to count the days between one and the other.
The question is, if an arrival date is Feb 23 and Departure March 15, from
the 20 days difference, I just want to count the days stayed this month,
March.
How can I write a query to return this please?
Thanks in advance!
MRC

Assuming that this-month is dependent on the CURRENT date and
Departure date is always in the current month.

CurrMonthDays = datediff("d",(Date() -
Datepart("d",Date()),DepartureDate)


The key is to compute the from date for the datediff as the last day
of the previous month.

Ron
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top