Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 8
Default If statement comparing times

Hi;

I am trying to write a formula that will let me compare times and assign a
shift value (1st or 2nd Shift) based on that..... and I can't get it to work.

Here is my current forumla:

=IF(AND($S2TIME(4,0,0),($S2<TIME(15,0,0))),"1st Shift","2nd Shift")

Which is supposed to say that if the time in S2 is greater than 4:00AM and
less than 3:00PM, it is 1st Shift, else it is 2nd Shift.

The value is S2 is formatted as "6:00", and is a copy of another cell that
is formatted "06/25/2009 06:00". The only value that this formula will return
- for all values - is "2nd Shift."

How to fix? Thanks for the help.


  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,389
Default If statement comparing times

Formatting doesn't change the underlying value of a cell. It changes only
how it's displayed. To ignore the date, and consider only the time, that's
in the cell, use:
=IF(AND(MOD($S2,1)TIME(4,0,0),MOD($S2,1)<TIME(15, 0,0)),"1st Shift","2nd
Shift")

Regards,
Fred.

"GoBrowns!" wrote in message
...
Hi;

I am trying to write a formula that will let me compare times and assign a
shift value (1st or 2nd Shift) based on that..... and I can't get it to
work.

Here is my current forumla:

=IF(AND($S2TIME(4,0,0),($S2<TIME(15,0,0))),"1st Shift","2nd Shift")

Which is supposed to say that if the time in S2 is greater than 4:00AM and
less than 3:00PM, it is 1st Shift, else it is 2nd Shift.

The value is S2 is formatted as "6:00", and is a copy of another cell that
is formatted "06/25/2009 06:00". The only value that this formula will
return
- for all values - is "2nd Shift."

How to fix? Thanks for the help.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Comparing 2 dates and times bollard Excel Worksheet Functions 3 May 8th 08 05:12 PM
Comparing times.. [email protected] Excel Worksheet Functions 1 November 25th 07 03:16 AM
Comparing two times changetires Excel Discussion (Misc queries) 2 July 26th 06 10:25 PM
Comparing Times Just Learning Excel Discussion (Misc queries) 4 August 19th 05 06:27 PM
Comparing Times trumpy81 New Users to Excel 2 June 29th 05 11:01 AM


All times are GMT +1. The time now is 04:10 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"