Time Format to Text Output - A Tough One !

J

John Calder

Hi

I run Excel 2K

I have a series of times that I download from the mainframe. (these are in a
date format)

EXAMPLE
23/09/2009 6:07:00 AM
22/09/2009 9:22:00 PM
22/09/2009 7:40:00 PM

etc etc

I am in need of a formula that looks at these times, and based on their
values, displays a particular piece of text. (in this case "DAY", "AFT",
"NIGHT")

Example

Any time between the following:
7:20:00 AM to 3:19:00 PM should display the word DAY

Any time between the following:
3:20:00 PM to 11:19:00PM should display the word AFT

Any time between the following:
11:20:00 PM to 7:19:00 AM should display the word NIGHT

Assume the original time is in cell B8

Thanks

John
 
J

John Calder

Hi

Further to my previous post I have tried the following formula.
It almost works, it displays the Day and the Aft ok but where the Night
should be shows only a blank cell.

=IF(AND(TEXT(B8-INT(B8),"hh:mm:ss")>="07:20:00",TEXT(B8-INT(B8),"hh:mm:ss")<"15:20:00"),"Day",IF(AND(TEXT(B8-INT(B8),"hh:mm:ss")>="15:20:00",TEXT(B8-INT(B8),"hh:mm:ss")<"23:20:00"),"Aft",IF(AND(TEXT(B8-INT(B8),"hh:mm:ss")>="23:20:00",TEXT(B8-INT(B8),"hh:mm:ss")<"07:20:00"),"Night","")))


I hope this helps

Thanks

John
 
M

Ms-Exl-Learner

Try this.

=IF(A1="","",IF(AND(--TEXT(A1,"HH:MM:SS")>=TIME(7,20,0),(--TEXT(A1,"HH:MM:SS")<=TIME(15,19,59))),"DAY",IF(AND(--TEXT(A1,"HH:MM:SS")>=TIME(15,20,0),(--TEXT(A1,"HH:MM:SS")<=TIME(23,19,59))),"AFT","NIGHT")))

change the cell reference A1 to your desired cell.

If this post helps, Click Yes!
 
J

John Calder

Joe

Thanks for your repsonse. The difference is that the earlier post was for a
formula that looked at a 2 X 12 hr shift operation and the one I need now is
for a 3 X 8 hr operation.

I hadnt worked out how to ammend the earlier one to suit the later one so I
posted it again with the new criteria.

As a result from this groups help I now have it working.

Thanks you very much, it was much appreciated.

John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top