0

I am trying to generate a cell on my shift report for work that automatically differentiates if it is for day-shift or night-shift. Our shifts are 12 hours (7-7), and shift reports are generally sent out within a 60 minute window around the turnover time (6:30-7:30).

My code is currently: IF(NOW()>="8:00 AM","D","N")

I read this code as "if current time is greater than or equal to 8AM, display "D". If the current time is less than 8AM, display "N"." I have set the time as 8:00 AM to ensure that night shift report will stay labeled as "N" up to an hour after the designated shift end. This is to ensure proper labeling even in the case the shift report is delayed (up to one hour).

Currently the code is not behaving as desired but i'm not actually sure what it is doing. Any advice on where i'm going wrong?

  • 1
    `=IF(MOD(NOW(),1)>=TIME(8,0,0),"D","N")` – Spectral Instance Jul 10 '22 at 16:11
  • Thanks, that seems to work. Can you explain the use of the mod function. It appears to be necessary (I tried removing it to see the result), but I don't understand its function in this case. Either way, thank you. – FalcoonnnnPUNCH Jul 10 '22 at 16:19
  • The `NOW()` function returns the sum of the current date (an integral number) _and_ the current time (a decimal number < 1) - nesting it inside the `MOD()` function strips out the date component, by returning the remainder after dividing by 1. – Spectral Instance Jul 10 '22 at 16:27
  • I am having trouble accepting your answer. To my knowledge, waiting 15 minutes is the only prerequisite, it shouldn't matter that my account is new or that I don't have any rep, is that correct? – FalcoonnnnPUNCH Jul 10 '22 at 16:44
  • Only an answer can be accepted, whereas I posted a comment (which you can upvote if you want). – Spectral Instance Jul 10 '22 at 16:47
  • oooh, I gotcha. I am unable to upvote until I obtain 15 reputation. – FalcoonnnnPUNCH Jul 10 '22 at 17:15

0 Answers0