Days, Weeks, And Months

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have 2 dates I want to know how many days weeks and months went by (for
rental purpose)
I did Days: [Date in]-[Date Out] and this gives me a flat number of days (26
days, 13 days, 93 days)
but I want to know how many days, weeks, and months went by (Example: 24
Days = 3 weeks and 3 days, so 3*25 (weekly Rental) + 3*5 (Daily Rental) total
= 90)
Thanks
Aron
 
Hi, Aron.

If you have a table listing the monthly, weekly and daily rates for the
calculation, then try the following:

SELECT [Date in], [Date Out],
DateAdd("m", NumMos, [Date in]) AS WkFrDate,
DateAdd("ww", NumWks, WkFrDate) AS DayFrDate,
DateDiff("m", [Date in], [Date Out]) AS Mos,
IIF((DateAdd("m", Mos, [Date in]) <= [Date Out]), Mos, (Mos - 1)) AS
NumMos,
DateDiff("w", WkFrDate, [Date Out]) AS NumWks,
DateDiff("d", DayFrDate, [Date Out]) AS NumDays,
NumMos *
(SELECT Rate
FROM tblRates
WHERE (Period = 'Monthly')) +
NumWks *
(SELECT Rate
FROM tblRates
WHERE (Period = 'Weekly')) +
NumDays *
(SELECT Rate
FROM tblRates
WHERE (Period = 'Daily')) AS Cost
FROM tblRentals;

.... where Rate is a field of Currency data type, Period is a text field for
the time frame for each rate, tblRates is the name of the table listing the
rates, and tblRentals is the name of the table storing the dates and other
information for each rental.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.
 

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

Week, monthly, quarterly 2
Month, DATE, Week 7
Monthly quantities to Weekly 1
rental equipment invoice 1
Query Date Range 1
Date Range 7
Select data and sum by weeks in a month 3
looking for a better way 1

Back
Top