Formula for Date\Time

Freeman2022

New Member
Joined
Nov 3, 2021
Messages
41
Office Version
  1. 365
Platform
  1. Windows
Hello,

Can someone please help me with the below, I'm looking for a formula that would give me the information below. Thanks in advance

If column A is Monday - Thursday and time is 9PM to 6AM then Column B = Afterhours, if not then Column B = Business Hours
If column A is Friday and time is 5PM to 6AM then Column B = Afterhours, if not then Column B = Business Hours
If column A is Sat or Sun then Column B = Afterhours
 

Attachments

  • Afterhours vs Business Hours.PNG
    Afterhours vs Business Hours.PNG
    11 KB · Views: 6

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
MrExcelPlayground16.xlsx
AB
1Date Time
23/10/2023 9:40Business Hours
33/10/2023 14:39Business Hours
43/10/2023 21:41Afterhours
53/11/2023 7:36Afterhours
63/11/2023 16:55Afterhours
73/12/2023 3:31Afterhours
83/12/2023 6:02Afterhours
93/12/2023 16:21Afterhours
103/12/2023 17:49Afterhours
113/13/2023 2:18Afterhours
123/13/2023 9:05Business Hours
133/13/2023 20:31Business Hours
143/14/2023 6:08Business Hours
153/14/2023 17:04Business Hours
163/14/2023 23:37Afterhours
173/15/2023 7:30Business Hours
183/15/2023 9:50Business Hours
193/15/2023 17:37Business Hours
203/15/2023 18:45Business Hours
213/15/2023 22:17Afterhours
223/15/2023 23:51Afterhours
233/16/2023 4:10Afterhours
243/16/2023 11:36Business Hours
253/16/2023 19:14Business Hours
263/17/2023 0:10Afterhours
273/17/2023 9:15Business Hours
283/17/2023 16:00Business Hours
Sheet22
Cell Formulas
RangeFormula
B2:B28B2=IF(WEEKDAY(A2,11)<5,IF(AND(HOUR(A2)>=6,HOUR(A2)<21),"Business Hours","Afterhours"),IF(WEEKDAY(A2,11)=5,IF(AND(HOUR(A2)>=6,HOUR(A2)<17),"Business Hours","Afterhours"),"Afterhours"))
 
Upvote 0
Solution
MrExcelPlayground16.xlsx
AB
1Date Time
23/10/2023 9:40Business Hours
33/10/2023 14:39Business Hours
43/10/2023 21:41Afterhours
53/11/2023 7:36Afterhours
63/11/2023 16:55Afterhours
73/12/2023 3:31Afterhours
83/12/2023 6:02Afterhours
93/12/2023 16:21Afterhours
103/12/2023 17:49Afterhours
113/13/2023 2:18Afterhours
123/13/2023 9:05Business Hours
133/13/2023 20:31Business Hours
143/14/2023 6:08Business Hours
153/14/2023 17:04Business Hours
163/14/2023 23:37Afterhours
173/15/2023 7:30Business Hours
183/15/2023 9:50Business Hours
193/15/2023 17:37Business Hours
203/15/2023 18:45Business Hours
213/15/2023 22:17Afterhours
223/15/2023 23:51Afterhours
233/16/2023 4:10Afterhours
243/16/2023 11:36Business Hours
253/16/2023 19:14Business Hours
263/17/2023 0:10Afterhours
273/17/2023 9:15Business Hours
283/17/2023 16:00Business Hours
Sheet22
Cell Formulas
RangeFormula
B2:B28B2=IF(WEEKDAY(A2,11)<5,IF(AND(HOUR(A2)>=6,HOUR(A2)<21),"Business Hours","Afterhours"),IF(WEEKDAY(A2,11)=5,IF(AND(HOUR(A2)>=6,HOUR(A2)<17),"Business Hours","Afterhours"),"Afterhours"))
Works PERFECTLY!!!!!! Thank you so much
 
Upvote 0
This is the based on about 15 minutes of work. Maybe there is somthing simpler
=LET(WD,WEEKDAY(A2,2),T,TIME(HOUR(A2),MINUTE(A2),SECOND(A2)),IF(OR(OR(AND(WD>=1,WD<=4,OR(T<TIMEVALUE("06:00:00"),T>TIMEVALUE("21:00:00"))),AND(WD=5,OR(T<TIMEVALUE("06:00"),T>TIMEVALUE("17:00"))),WD>5)),"Afterhours","Business Hours"))
 
Upvote 0

Forum statistics

Threads
1,215,220
Messages
6,123,693
Members
449,117
Latest member
Aaagu

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