ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   If statement with time values (https://www.excelbanter.com/excel-worksheet-functions/204831-if-statement-time-values.html)

Dave Naples

If statement with time values
 
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),K3TIME(6,59,0)),"DAY","NI GHT")

Could it have to do with my time format for column K? Any help would be
greatly appreciated

bpeltzer

If statement with time values
 
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)).

"Dave Naples" wrote:

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),K3TIME(6,59,0)),"DAY","NI GHT")

Could it have to do with my time format for column K? Any help would be
greatly appreciated


Dave Naples[_2_]

If statement with time values
 
Thanks. That seems to have worked perfectly.

Dave


"bpeltzer" wrote:

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)).

"Dave Naples" wrote:

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),K3TIME(6,59,0)),"DAY","NI GHT")

Could it have to do with my time format for column K? Any help would be
greatly appreciated



All times are GMT +1. The time now is 12:09 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com