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

Similar Threads

Date Range 7
Date Difference In Query 2
Query with IIF Expression Need Help 4
Select by alternative date if one is null 3
Update SQL 1
date period query 5
SQL Mix up? 3
Date Query using date in the date field 3

Top