Formula to count days

Jendjieh

New Member
Joined
Feb 9, 2022
Messages
8
Office Version
  1. 365
Platform
  1. Windows
I need help with a simple formula to calculate the difference between days.
So I have 3 columns, the first two show day abbreviations as MON, TUE, WED, THU, FRI, SAT, SUN and the third one gives you the difference between a day in column two vs column one.
Example: Col 1: MON, Col 2: THU, Col 3: 3 (as THU - MON so 4 - 1 = 3)
I made a little table on the side to tell excel that MON = 1, TUE = 2 etc. and am using vlookups to deduct the first value from the second, absolute values.
However, it's not working in case column 1 shows a "higher" day than column 2, I used absolute values to overcome this, but it does not work how I wanted.
And if I have Col 1: WED, COL 2: TUE, Col 3 shows 1, but it should be 7... (THU, FRI, SAT, SUN, MON, TUE, WED)
In short: I need to calculate the actual number of days passed between two weekdays, without specific dates attached.
Is it something possible to achieve using a formula?
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
How about
+Fluff 1.xlsm
ABCDE
1
2wedtue6Mon
3monthu3Tue
4Wed
5Thu
6Fri
7Sat
8Sun
Lists
Cell Formulas
RangeFormula
C2:C3C2=MATCH(B2,$E$2:$E$8,0)-MATCH(A2,$E$2:$E$8,0)+IF(MATCH(B2,$E$2:$E$8,0)<MATCH(A2,$E$2:$E$8,0),7,0)
 
Upvote 0
Solution
How about
+Fluff 1.xlsm
ABCDE
1
2wedtue6Mon
3monthu3Tue
4Wed
5Thu
6Fri
7Sat
8Sun
Lists
Cell Formulas
RangeFormula
C2:C3C2=MATCH(B2,$E$2:$E$8,0)-MATCH(A2,$E$2:$E$8,0)+IF(MATCH(B2,$E$2:$E$8,0)<MATCH(A2,$E$2:$E$8,0),7,0)
Thank you so much!
 
Upvote 0
Another similar to Fluff's in cell F2 and copied down. =MOD(MATCH(B2,$E$2:$E$8,0)-MATCH(A2,$E$2:$E$8,0),7)


A
B
C
D
E
F
1
2
wed​
tue​
6​
Mon​
6​
3
mon​
thu​
3​
Tue​
3​
4
Wed​
5
Thu​
6
Fri​
7
Sat​
8
Sun​
 
Upvote 0
Another similar to Fluff's in cell F2 and copied down. =MOD(MATCH(B2,$E$2:$E$8,0)-MATCH(A2,$E$2:$E$8,0),7)



A
B
C
D
E
F
1
2
wed​
tue​
6​
Mon​
6​
3
mon​
thu​
3​
Tue​
3​
4
Wed​
5
Thu​
6
Fri​
7
Sat​
8
Sun​
It works as well, thank you!
I don't understand the usage of MOD here, do you divide numbers by 7?
 
Upvote 0
It works as well, thank you!
I don't understand the usage of MOD here, do you divide numbers by 7?
It returns the correct count whether you subtract the smaller from the larger or the larger from the smaller. MOD returns the remainder in a division operation. I chose to divide by 7 because there are 7 days in a week. The remainder is always correct.

I you are interested the same strategy is often employed when computing times where it is possible the start time is PM and the end time is AM. (hint: in those cases the divisor is 1 and the remainders will be decimal fractions.)

Did this help?
 
Upvote 0
It returns the correct count whether you subtract the smaller from the larger or the larger from the smaller. MOD returns the remainder in a division operation. I chose to divide by 7 because there are 7 days in a week. The remainder is always correct.

I you are interested the same strategy is often employed when computing times where it is possible the start time is PM and the end time is AM. (hint: in those cases the divisor is 1 and the remainders will be decimal fractions.)

Did this help?
I had to analyze a few examples for my brain to finally get it, but now I do understand how it works.
Thank you again, I love to learn new things :)
 
Upvote 0

Forum statistics

Threads
1,214,951
Messages
6,122,442
Members
449,083
Latest member
Ava19

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