ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Count no of nights between dates (https://www.excelbanter.com/excel-worksheet-functions/224033-count-no-nights-between-dates.html)

Morten

Count no of nights between dates
 
I am trying to count no of nights for example stayed in a hotel,

For example
You put in the dates in row 1
Fill then row 2 with "x" if stayed at hotel

Need then another cell to calculate the number of nights that has been
stayed at the hotel (the cells filled with "x").

Can anyone help?

In advance thanks for your help

ExcelBanter AI

Answer: Count no of nights between dates
 
To count the number of nights stayed at a hotel, follow these steps:
  1. In a new cell, enter the formula: =DATEDIF(start_date, end_date, "d")
    Replace "start_date" with the cell reference of the first date in your row 1, and "end_date" with the cell reference of the last date in your row 1.
  2. Press Enter to calculate the number of days between the start and end dates.
  3. To convert the number of days to the number of nights, subtract 1 from the result. This is because the check-in day is not counted as a night, but the check-out day is.
  4. To count the number of nights stayed at the hotel, you can use the COUNTIF function. Enter the formula: =COUNTIF(row_2, "x")
    Replace "row_2" with the row number where you have marked "x" for the nights stayed at the hotel.
  5. Press Enter to calculate the number of nights stayed at the hotel.
  6. To combine the two formulas, enter the formula: =DATEDIF(start_date, end_date, "d")-1-COUNTIF(row_2, "x")
    This will give you the number of nights stayed at the hotel between the start and end dates.

RonaldoOneNil

Count no of nights between dates
 
Use Countif which takes a range and criteria
e.g.
=COUNTF(B2:K2,"x")

"Morten" wrote:

I am trying to count no of nights for example stayed in a hotel,

For example
You put in the dates in row 1
Fill then row 2 with "x" if stayed at hotel

Need then another cell to calculate the number of nights that has been
stayed at the hotel (the cells filled with "x").

Can anyone help?

In advance thanks for your help


Stefi

Count no of nights between dates
 
=COUNTIF(B:B,"x")
I supposed that you meant COLUMN A for dates and COLUMN B for x's.

Regards,
Stefi

€˛Morten€¯ ezt Ć*rta:

I am trying to count no of nights for example stayed in a hotel,

For example
You put in the dates in row 1
Fill then row 2 with "x" if stayed at hotel

Need then another cell to calculate the number of nights that has been
stayed at the hotel (the cells filled with "x").

Can anyone help?

In advance thanks for your help


Morten

Count no of nights between dates
 
Thanks for the quick response.

I am afraid it does not give me the correct answer. I need the number of
nights between the dates, eg 3 days = 2 nights between 11th March - 13th
March.




RonaldoOneNil skrev:

Use Countif which takes a range and criteria
e.g.
=COUNTF(B2:K2,"x")

"Morten" wrote:

I am trying to count no of nights for example stayed in a hotel,

For example
You put in the dates in row 1
Fill then row 2 with "x" if stayed at hotel

Need then another cell to calculate the number of nights that has been
stayed at the hotel (the cells filled with "x").

Can anyone help?

In advance thanks for your help


David Biddulph[_2_]

Count no of nights between dates
 
If you need to reduce a number by 1, the function to use is subtraction.
Excel uses a minus sign for subtraction.
If you want an answer of COUNTIF(B2:K2,"x")-1, the formula to use is
=COUNTIF(B2:K2,"x")-1
--
David Biddulph

"Morten" wrote in message
...
Thanks for the quick response.

I am afraid it does not give me the correct answer. I need the number of
nights between the dates, eg 3 days = 2 nights between 11th March - 13th
March.

RonaldoOneNil skrev:

Use Countif which takes a range and criteria
e.g.
=COUNTF(B2:K2,"x")

"Morten" wrote:

I am trying to count no of nights for example stayed in a hotel,

For example
You put in the dates in row 1
Fill then row 2 with "x" if stayed at hotel

Need then another cell to calculate the number of nights that has been
stayed at the hotel (the cells filled with "x").

Can anyone help?

In advance thanks for your help





All times are GMT +1. The time now is 07:59 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com