Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Writing an IF statement for a Time Format value

Status
Not open for further replies.

Airbiskit

Technical User
May 20, 2003
89
GB
Hi,

I have a large spreadsheet that consists of the following Fields...
Start Time, Finish Time, Total Hours.

The Start Time and Finish time are in time format (eg "00:00:00").

I am trying to write an if statement on the lines of

=IF(A1>00:00:00 AND B1<06:00:00, "Y", "N")

Excel doesn't like it, I think due to the time format, how do I get this to work?

Thanks

Steve
 
This is more like what you want:
Code:
=IF(AND(A1>TIMEVALUE("00:00:00"),B1<TIMEVALUE("06:00:00")), "Y", "N")

Look at the help for the AND function and the OR functions for use within logical testing.

Also look at Skip's FAQ on dates and times, as you may not realise that 6:00 is the same as 0.25 ( that comes from 6/24 by the way ). So your IF function can be converted to:
Code:
=IF(AND(A1>0,B1<0.25), "Y", "N")


Cheers, Glenn.

Did you hear about the literalist show-jumper? He broke his nose jumping against the clock.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top