excel - Equating time values in IF statement -
good morning,
i having issue whereby logical statements regarding time values not evaluating expected.
is there known issue equating recurring decimals logically?
for clarity here sample of code in question.
function comparetimes(timecurrent, timestart, timeend, timebreak1, optional timelunch variant, optional timebreak2 variant) if timecurrent >= timestart , timecurrent < timeend if timecurrent = timebreak1 or timecurrent = timebreak2 comparetimes = "b" elseif ismissing(timelunch) = false timelunchend = timelunch + (1 / 48) if timecurrent >= timelunch , timecurrent < timelunchend comparetimes = "l" else comparetimes = 1 end if else comparetimes = 1 end if else comparetime = 0 end if end function
all arguments of function excel times in form h:mm. example of error 2nd if statement - when timecurrent , timebreak1 same cell in excel, function outputs "b" expected. if timecurrent , timebreak1 in different cells same value (e.g 12:00) returns 1 instead.
any on understanding logicals , floating points appreciated.
though may showing time h:mm, excel stores full value including seconds. if change cell formatting h:mm:ss, values may not "identical" assumed. times stored date.time where, numbers before decimal represent days , after decimal represent fractional part of 24 hour day (ie 0.5 = 12:00 noon). try changing formatting of cells show date , time sure entire "date value" consistent expectations.
the variables time should defined double ensure there no issues data types being considered. it's not clear how time entered.
Comments
Post a Comment