• Status: Solved
• Priority: Medium
• Security: Public
• Views: 336

# time formatting in formula

hi Folks
I've created this formula...the idea being that if the status column shows less than 5 minutes and H3 is not the same as h2, it should show up as transient
=IF(AND(H3<>H2,TEXT([@Status],"[mm]:ss")<5),"transient","resident"). However when I copy down the formula, everything is showing as resident and I think it's to do with the 5 in my formula. I've formatted the status column as time.
How can I show my 5 as five minutes or is there something else?
Thanks as always..
0
agwalsh
4 Solutions

Commented:
Try this

=IF(AND(H3<>H2,ROUND(C9*1440,0))<5),"transient","resident")

Enter the time in the Cell c9 in the format HH:MM
0

Finance AnalystCommented:
It may help to give a quick explanation of how excel works with date and time.

Date = Integer count of days since 01/01/1900 giving a serial number eg today (10 Jan 2014) is 41649.

Time = decimal portion of a day, therefore 41649.5 would be 12:00 noon today; divisble into 24 hours or 1440 minutes (24 * 60) or 86400 seconds (24 * 60 * 60)

Thereby all values for time alone are less than 1, hence why all your items were less than 5.

I assume your [@Status] is because the data range is set to a table rather than a list so the corrected formula would be:

=IF(AND(H3<>H2,[@Status]<5/1440),"transient","resident")

Thanks
Rob H
0

Commented:
It's also possible to use this approach

=IF(AND(H3<>H2,[@Status]<"0:05"+0),"transient","resident")

...or you might find it simpler to use TIME function like this:

=IF(AND(H3<>H2,[@Status]<TIME(0,5,0)),"transient","resident")

regards, barry
0

Author Commented:
@Kujumbio - tried your approach and I can see it's nearly there..Couple of questions though..

=IF(AND(H3<>H2,ROUND(C9*1440,0))<5),"transient","resident")
simply because c9 wasn't a relevant cell

I adjusted it to:

=IF(AND(H4<>H3,ROUND([@Status]*1440,0)<5),"transient","resident").
Unfortunately this is still giving me "resident status"
I also formatted Status as "[HH]:mm" but I'm still getting all Residents.

Would the following have any impact? I've used =TEXT(A3-A2,"[h]:mm:ss") to extract the Time Elapsed and =TEXT([@[Time Elapsed]],"[HH]:mm") to show Status..

I'm attaching a sample file to illustrate. Thanks for all your help. Much appreciated.
I've tried all your approaches as you can see in the file but reckon I'm missing something in my time formatting..
EE--If-on-time.xlsx
0

Finance AnalystCommented:
Looks like the problem is because you are converting all time values to text.

Time Elapsed can just be =A3-A2, then format as "[h]:mm:ss"

What are you trying to achieve with status column? Currently it is just converting Time Elapsed to text but, with current formula, its already text.

Thanks
Rob
0

Author Commented:
Have awarded you all points because you all helped to the solution - which eventually I did as:
=IF(AND(H5=H4,[@[Time Elapsed]]>TIME(0,5,0)),"resident","transient")
I gave BarryHoudini best solution because his answer was the closest to what I eventually got working for me. But THANK YOU as always to all of you :-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

## Featured Post

Tackle projects and never again get stuck behind a technical roadblock.