В Excel (или числах) по какой формуле можно рассчитать количество дней в определенном месяце на 2 даты

1902
tom

Если гость прибыл 24 августа и уехал 4 сентября, по какой формуле рассчитывается, сколько ночей проведено в августе и сколько ночей проведено в сентябре?

4
Вы хотите включить 4 сентября или исключить его из числа ночей ?? Gary's Student 8 лет назад 0
Может ли пребывание продлиться три календарных месяца? fixer1234 8 лет назад 0

2 ответа на вопрос

3
jcbermu

Supposing the arrival date is in A1 and the check out date is in B1 then on C1 you must put:

=IF(EOMONTH(A1,0)<B1,CONCATENATE((EOMONTH(A1,0)-A1)," and ",B1-A1-(EOMONTH(A1,0)-A1)-1),B1-A1) 

explanation:

IF ( EOMONTH(A1,0)<B1 //If last day of month of arrival is before the checkout date then CONCATENATE( //concatenate days of first month "and" days of next month (EOMONTH(A1,0)-A1), " and ", B1-A1-(EOMONTH(A1,0)-A1)-1 ) B1-A1 //Else, simply substract checkout date from arrival date. 
3
Máté Juhász

Below is a table to split by month number of nights regardless of how many months are included:
enter image description here

Note that even if only month names appear in first row those are actually dates: first days of the months formatted to show only month name ("mmmm")

Formula in the table is:
=NOT(OR(D$1>$B2,EOMONTH(D$1,0)<$A2))*(MIN(EOMONTH(D$1,0)+1,$B2)-MAX(D$1,$A2))

  • NOT(OR(D$1>$B2,EOMONTH(D$1,0)<$A2)) is to decide whether current stay and month overlap
  • MIN(EOMONTH(D$1,0)+1,$B2)-MAX(D$1,$A2) is the length of stay

Calculations are done as I found it in hotels: night is counted to previous day (row 4 is one night in august) and one day stay is not counted as a night (see row 5)

Предложение; Переместите полную формулу после `в таблице` на одну строку, чтобы ее было легче читать. Hannu 8 лет назад 2
Это работает хорошо для меня, большое спасибо! tom 8 лет назад 0

Похожие вопросы