Query Date Range

  • Thread starter Thread starter MRCUSA
  • Start date Start date
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
 
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
 
Back
Top