If a date is between 2 different Dates then Return Week Number

SiuGuy007

New Member
Joined
Jun 19, 2015
Messages
40
I am not 100% sure how to write the formula for this? On Sheet 1, I have various dates for new hired EE's. On Sheet 2, I have a list of "From Date" and "To Date", with the corresponding Week number.

If the New Hired EE date falls between the From and To Dates, I need to have the result return the week number.

[TABLE="width: 460"]
<colgroup><col span="2"><col><col><col></colgroup><tbody>[TR]
[TD]From Date[/TD]
[TD]To Date[/TD]
[TD]Week number[/TD]
[TD][/TD]
[TD]New Hire EE[/TD]
[/TR]
[TR]
[TD]January 1, 2018[/TD]
[TD]January 7, 2018[/TD]
[TD]Week 01[/TD]
[TD][/TD]
[TD]1/4/2018[/TD]
[/TR]
[TR]
[TD]January 8, 2018[/TD]
[TD]January 14, 2018[/TD]
[TD]Week 02[/TD]
[TD][/TD]
[TD]1/5/2018[/TD]
[/TR]
[TR]
[TD]January 15, 2018[/TD]
[TD]January 21, 2018[/TD]
[TD]Week 03[/TD]
[TD][/TD]
[TD]1/6/2018[/TD]
[/TR]
[TR]
[TD]January 22, 2018[/TD]
[TD]January 28, 2018[/TD]
[TD]Week 04[/TD]
[TD][/TD]
[TD]1/7/2018[/TD]
[/TR]
[TR]
[TD]January 29, 2018[/TD]
[TD]February 4, 2018[/TD]
[TD]Week 05[/TD]
[TD][/TD]
[TD]1/8/2018[/TD]
[/TR]
</tbody>[/TABLE]

Any assistance is greatly appreciated.

SIUGuy007
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Hi,

You can use LOOKUP or INDEX/MATCH:


Book1
ABCDEFG
1From DateTo DateWeek numberNew Hire EELOOKUPINDEX/MATCH
21-Jan-187-Jan-18Week 011/4/2018Week 01Week 01
38-Jan-1814-Jan-18Week 021/5/2018Week 01Week 01
415-Jan-1821-Jan-18Week 031/6/2018Week 01Week 01
522-Jan-1828-Jan-18Week 041/7/2018Week 01Week 01
629-Jan-184-Feb-18Week 051/8/2018Week 02Week 02
Sheet44
Cell Formulas
RangeFormula
F2=LOOKUP(E2,A$2:A$6,C$2:C$6)
G2=INDEX(C$2:C$6,MATCH(E2,A$2:A$6,1))


Either way, formula copied down.
 
Upvote 0
My apologies for the delay in acknowledging your prompt reply and answer to my question. Very much appreciated. The Lookup formula did not work, however, the Match formula did.

Thanks again,

SIUGuy
 
Upvote 0
One other quick question. Instead of returning the week number (E2), I would like to count the total number of dates between the from and to periods.
 
Upvote 0
I'm not sure I understanding your new question.

Are you saying the number of days FROM and TO columns A & B, each line separately, or Total (A2 to B6)?
Or are you saying the number of days within FROM and TO COLUMNS A & B, Starting with Hire date (column E), each line separately?

Please give sample and desired results.
 
Upvote 0
Thank you for your reply. I guess I should say it this way. If an EE Hire date is between 2 different Dates (From and To Date) then Return the count. Example below.

[TABLE="width: 443"]
<colgroup><col><col><col><col><col></colgroup><tbody>[TR]
[TD]EE Hire Date[/TD]
[TD]From Date[/TD]
[TD]To Date[/TD]
[TD] Week #[/TD]
[TD]Results[/TD]
[/TR]
[TR]
[TD]4/6/2018[/TD]
[TD]4/2/2018[/TD]
[TD="align: right"]4/8/2018[/TD]
[TD] Week 14[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]4/14/2018[/TD]
[TD]4/9/2018[/TD]
[TD="align: right"]4/15/2018[/TD]
[TD] Week 15[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]4/25/2018[/TD]
[TD]4/16/2018[/TD]
[TD="align: right"]4/22/2018[/TD]
[TD] Week 16[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]4/25/2018[/TD]
[TD]4/23/2018[/TD]
[TD="align: right"]4/29/2018[/TD]
[TD] Week 17[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]4/25/2018[/TD]
[TD]4/30/2018[/TD]
[TD="align: right"]5/6/2018[/TD]
[TD] Week 18[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD="align: right"][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
I'm not following the logic/math in your sample results above, please explain How you got 1, 1, 0, 3, 1?
 
Upvote 0
Under EE Hire date, there is 1 new hire on 4/6/18. This is the only new hire date that fell between 4/2/18 to 4/8/18. 4/6/18 equals 1.
Under EE Hire date, there 3 new hires on 4/25/18. These 3 new hire dates fell between 4/23/18 to 4/29/18. Those 3 dates equal 3.
And so on!
 
Upvote 0
Thank you for your reply. I guess I should say it this way. If an EE Hire date is between 2 different Dates (From and To Date) then Return the count. Example below.

[TABLE="width: 443"]
<tbody>[TR]
[TD]EE Hire Date
[/TD]
[TD]From Date
[/TD]
[TD]To Date
[/TD]
[TD] Week #
[/TD]
[TD]Results
[/TD]
[/TR]
[TR]
[TD]4/6/2018
[/TD]
[TD]4/2/2018
[/TD]
[TD="align: right"]4/8/2018
[/TD]
[TD] Week 14
[/TD]
[TD]1
[/TD]
[/TR]
[TR]
[TD]4/14/2018
[/TD]
[TD]4/9/2018
[/TD]
[TD="align: right"]4/15/2018
[/TD]
[TD] Week 15
[/TD]
[TD]1
[/TD]
[/TR]
[TR]
[TD]4/25/2018
[/TD]
[TD]4/16/2018
[/TD]
[TD="align: right"]4/22/2018
[/TD]
[TD] Week 16
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]4/25/2018
[/TD]
[TD]4/23/2018
[/TD]
[TD="align: right"]4/29/2018
[/TD]
[TD] Week 17
[/TD]
[TD]3
[/TD]
[/TR]
[TR]
[TD]4/25/2018
[/TD]
[TD]4/30/2018
[/TD]
[TD="align: right"]5/6/2018
[/TD]
[TD] Week 18
[/TD]
[TD]1
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD="align: right"][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

But you're showing 1 hire in red above, that's what threw me off.
 
Upvote 0

Forum statistics

Threads
1,223,719
Messages
6,174,089
Members
452,542
Latest member
Bricklin

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