Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / April 2008

Tip: Looking for answers? Try searching our database.

Using time values with an IF

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Col - 24 Apr 2008 17:14 GMT
Hi all,

Is it possible to use hours and minutes (hh:mm) as the parameters in an IF
statement.

Regarding the formula below;

=IF(ISBLANK(E20),"",IF(E13<9,"Rest",IF(E13<11,1,"OK")))

The values in cell E13 is in hh:mm format, and as such the formula doesn't
compute.

I've tried changing the number 9 and 11 in the example above to

09:00

00:09:00

#09:00#

"09:00"

Without any success.

Can anyone please help me out with the correct syntax or suggest an
alternative - note I cannot change the cell format from hh:mm

Thank you,

Colin.
T. Valko - 24 Apr 2008 17:27 GMT
Try this:

=IF(E20="","",IF(HOUR(E13)<9,"Rest",IF(HOUR(E13)<11,1,"OK")))

Signature

Biff
Microsoft Excel MVP

> Hi all,
>
[quoted text clipped - 26 lines]
>
> Colin.
JE McGimpsey - 24 Apr 2008 17:30 GMT
Times in XL are stored as fractional days, so the stored value in the
cell displaying

  09:00

is  9/24 or 0.375, which you can see if you change the number format to
General.

So

  =IF(ISBLANK(E20),"",IF(E13<9/24,"Rest",IF(E13<11/24,1,"OK")))

should work for you.

> Hi all,
>
[quoted text clipped - 26 lines]
>
> Colin.
Pete_UK - 24 Apr 2008 17:32 GMT
You need to realise that times are stored internally by Excel as
fractions of a 24-hour day, so  6:00 is stored as 0.25, 18:00 as 0.75
etc. Thus you can't just refer to 9 directly in your formula if you
mean 9 hours.

You could do it like this:

=IF(ISBLANK(E20),"",IF(E13<9/24,"Rest",IF(E13<11/24,1,"OK")))

if the 9 and 11 both refer to hours. You could also use the TIME
function, like this:

=IF(ISBLANK(E20),"",IF(E13<TIME(9,0,0),"Rest",IF(E13<TIME(11,0,0),
1,"OK")))

which is a bit easier to understand.

Hope this helps.

Pete

> Hi all,
>
[quoted text clipped - 26 lines]
>
> Colin.
Col - 24 Apr 2008 18:38 GMT
Thank you very much everyone for your replies.

Regards,

> Hi all,
>
[quoted text clipped - 26 lines]
>
> Colin.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.