IF statement for after hours/normal hours mapping

genghiskhan

New Member
Joined
Jan 2, 2013
Messages
5
Hi all, I have only one date and time (e.g. 02/07/2012 08:00) in A2 for ambulance callouts. After hours for me means before 08:00 and after 18:00 Mon to Fri; before 08:00 and after 12:00 Sat; and all days Sundays and public holidays. Even it is not possible for public holidays for you because we might be in different countries, please advise how to map this date and time field to "After Hours" in B2. Thanks so much from Mongolia.
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Try:

=IF(OR(WEEKDAY(A2)=1,MOD(A2,1)<("08:00"+0),MOD(A2,1)>(IF(WEEKDAY(A2)=7,"12:00","18:00")+0)),"After Hours","")
 
Upvote 0
The MOD function returns the remainder after division of its first argument by its second argument. If the first argument is a date and time and its second argument is 1 the time will be returned (since dates and times are really just numbers).
 
Upvote 0
The MOD function returns the remainder after division of its first argument by its second argument. If the first argument is a date and time and its second argument is 1 the time will be returned (since dates and times are really just numbers).

thanks Andrew P. You are very kind. GK from Mongolia
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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