If statement with time values

  • Thread starter Thread starter Dave Naples
  • Start date Start date
D

Dave Naples

Hello:

I'd like to implement an if statement to return a value for whether the
time-of-day from a specific column is during the "day" or "night". I have
one column (K) with time in the hhmm format. I've attempted the following,
but it only gives me "night" as the result for all cases so something is not
working correctly.

=IF(AND(K3<TIME(19,0,0),K3>TIME(6,59,0)),"DAY","NIGHT")

Could it have to do with my time format for column K? Any help would be
greatly appreciated
 
You're comparing the full date/time (Oct 2 2008 8:15 AM) to just a time (6:59
AM). If you use just the fractional portion from column K, the comparison
should do what you're expecting. So where you have K3, I'd use
(k3-trunc(k3)).
 
Back
Top