Check if date is in vacation time

Beneindias

Board Regular
Joined
Jun 21, 2022
Messages
120
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Hi guys,

Trying to check if a date is between a range of dates in a table with date ranges.

So, I have a table with two columns, col C is first day of vacation and col D is last day.

And I'm trying to come up with a function to tell me if a given date is inside that range. I'm toying with countif, but I'm not getting the expected results.

The function that I came up is:

=IF(AND(COUNTIF(Tabela2[Início];"<"&CONCATENATE(B9;$AA$2;$AE$2));COUNTIF(Tabela2[Fim];">"&CONCATENATE(B9;$AA$2;$AE$2)));"VACATION";"WORK")

Row B has the days
AA2 have the month
AE2 have the year

My thinking to this function was, if that date is bigger than "Inicio" and smaller than "Fim", it's vacation time, but, as there are a few "ranges" of dates, the result is not right.

Right now, if I use "1-8-2022" it tells me that its vacation time, because its considering "18-4-2022" as smaller and "31-8-2022" and "31-12-2022" as bigger dates.
How can I do this? I know how to do it if I have single dates, but I was trying with date ranges to make this easier when updating the file.

Thanks to all
 

Attachments

  • Captura de ecrã 2022-11-15 104734.png
    Captura de ecrã 2022-11-15 104734.png
    4.4 KB · Views: 19

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Found the solution. Probably not the best way to do it, but I'm getting the expected values.

Had to scrap that function and used Index match instead.

This is the function that worked

=IF(AND(INDEX(Tabela2[Início];(MATCHTemplate!B10;Tabela2[Início];1));1)<=Template!B10;INDEX(Tabela2[Fim];(MATCH(Template!B10;Tabela2[Início];1));1)>=B10);"Vacation";"Work")
 
Upvote 0
Solution

Forum statistics

Threads
1,223,880
Messages
6,175,154
Members
452,615
Latest member
bogeys2birdies

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top