coding a value to appear if it's before 2pm and one for if it's after

zilch4ry

Board Regular
Joined
Feb 27, 2011
Messages
76
hi everyone,

if there a way of coding a formula to say "if it is before 2pm show the text "Shift 1" and if it is after 2pm to show the text "shift 2"- it sounds simple but i can't see any possible way of doing this :eek:

If anybody could help in anyway possible, it will be much appreciated

cheers,



tom
 

Some videos you may like

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

zilch4ry

Board Regular
Joined
Feb 27, 2011
Messages
76
I managed to produce this code:

Code:
=IF(AND(J3-INT(J3)>="14:00:00"+0,J3-INT(J3)<="22:00:00"+0),"Staff Shift 2","Staff Shift 1")

Can anybody help me to write that if the times are between "22:00 and 06:00" then the text will read "closed"

Thank you ;)
 

repairman615

Well-known Member
Joined
Dec 21, 2009
Messages
1,885
Hello,

<TABLE style="WIDTH: 294pt; BORDER-COLLAPSE: collapse" border=0 cellSpacing=0 cellPadding=0 width=392><COLGROUP><COL style="WIDTH: 294pt; mso-width-source: userset; mso-width-alt: 6272" width=392><TBODY><TR style="HEIGHT: 15.75pt" height=21><TD style="BORDER-BOTTOM: windowtext 0.5pt solid; BORDER-LEFT: windowtext 0.5pt solid; BACKGROUND-COLOR: #eaf1dd; WIDTH: 294pt; HEIGHT: 15.75pt; BORDER-TOP: windowtext 0.5pt solid; BORDER-RIGHT: windowtext 0.5pt solid" class=xl65 height=21 width=392>=IF(RIGHT(NOW(),4)>=3333," Shift 2"," Shift 1")</TD></TR></TBODY></TABLE>
 

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
47,926
Office Version
  1. 365
Platform
  1. Windows
if there a way of coding a formula to say "if it is before 2pm show the text "Shift 1" and if it is after 2pm to show the text "shift 2
Try

=IF(MOD(J3,1)<14/24,"Shift 1","Shift2")
 

repairman615

Well-known Member
Joined
Dec 21, 2009
Messages
1,885

ADVERTISEMENT

Maybe this for all three conditions:

<TABLE style="WIDTH: 774pt; BORDER-COLLAPSE: collapse" border=0 cellSpacing=0 cellPadding=0 width=1032><COLGROUP><COL style="WIDTH: 774pt; mso-width-source: userset; mso-width-alt: 16512" width=1032><TBODY><TR style="HEIGHT: 15.75pt" height=21><TD style="BORDER-BOTTOM: windowtext 0.5pt solid; BORDER-LEFT: windowtext 0.5pt solid; BACKGROUND-COLOR: #eaf1dd; WIDTH: 774pt; HEIGHT: 15.75pt; BORDER-TOP: windowtext 0.5pt solid; BORDER-RIGHT: windowtext 0.5pt solid" id=td_post_2653266 class=xl65 height=21 width=1032>=IF(MID(A3,FIND(".",A3,1),4)+0>=0.25,IF(AND(MID(A3,FIND(".",A3,1),4)+0>=0.3333,MID(A3,FIND(".",A3,1),4)+0<0.9166)," Shift 2"," Closed")," Shift 1")</TD></TR></TBODY></TABLE>
 

repairman615

Well-known Member
Joined
Dec 21, 2009
Messages
1,885
<TABLE style="WIDTH: 851pt; BORDER-COLLAPSE: collapse" border=0 cellSpacing=0 cellPadding=0 width=1134><COLGROUP><COL style="WIDTH: 851pt; mso-width-source: userset; mso-width-alt: 18144" width=1134><TBODY><TR style="HEIGHT: 15.75pt" height=21><TD style="BORDER-BOTTOM: windowtext 0.5pt solid; BORDER-LEFT: windowtext 0.5pt solid; BACKGROUND-COLOR: #eaf1dd; WIDTH: 851pt; HEIGHT: 15.75pt; BORDER-TOP: windowtext 0.5pt solid; BORDER-RIGHT: windowtext 0.5pt solid" id=td_post_2653266 class=xl65 height=21 width=1134>=IF(MID(NOW(),FIND(".",NOW(),1),4)+0>=0.25,IF(AND(MID(NOW(),FIND(".",NOW(),1),4)+0>=0.3333,MID(NOW(),FIND(".",NOW(),1),4)+0<0.9166)," Shift 2"," Closed")," Shift 1")</TD></TR></TBODY></TABLE>
 

Watch MrExcel Video

Forum statistics

Threads
1,122,517
Messages
5,596,619
Members
414,081
Latest member
Subaru_Steve

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
Top