PC Review


Reply
Thread Tools Rate Thread

Compare times : IF time < time2 then

 
 
david-witts@lycos.co.uk
Guest
Posts: n/a
 
      11th Jul 2006
Hi,

I'm stuck on a comarison of times problem.

My time column is formatted as "dd/mm/yyyy hh:mm:ss" although the
cell is formatted as hh:mm:ss

I'd like a comparison to say if the time is less than say 14:00 then
TRUE else FALSE but a simple IF (A2<$C$1,"TRUE","FALSE") doesn't work.

cell C1 is 14:00:00 formatted as hh:mm:ss

A simple time subtraction works OK ie A2-C1

If I could get rid of the DATE part of the field then the comparison
works OK. Trying a RIGHT function to just put the time part in a column
by itself doesn't work.

Any ideas, as I'm stuck.

regards

Davy

 
Reply With Quote
 
 
 
 
Pete_UK
Guest
Posts: n/a
 
      11th Jul 2006
Try this:

=IF(MOD(A2,1)<$C$1,"TRUE","FALSE")

assuming your date/time is in A2. If it is in the other cell, try this:

=IF(A2<MOD($C$1,1),"TRUE","FALSE")

Hope this helps.

Pete

david-(E-Mail Removed) wrote:
> Hi,
>
> I'm stuck on a comarison of times problem.
>
> My time column is formatted as "dd/mm/yyyy hh:mm:ss" although the
> cell is formatted as hh:mm:ss
>
> I'd like a comparison to say if the time is less than say 14:00 then
> TRUE else FALSE but a simple IF (A2<$C$1,"TRUE","FALSE") doesn't work.
>
> cell C1 is 14:00:00 formatted as hh:mm:ss
>
> A simple time subtraction works OK ie A2-C1
>
> If I could get rid of the DATE part of the field then the comparison
> works OK. Trying a RIGHT function to just put the time part in a column
> by itself doesn't work.
>
> Any ideas, as I'm stuck.
>
> regards
>
> Davy


 
Reply With Quote
 
david-witts@lycos.co.uk
Guest
Posts: n/a
 
      12th Jul 2006
Genius, thanks

this had me completely stuck. If you've got the time could you tell
me why it works?


Cell A2=30/11/1999 15:01:00

MOD(A2,1)=15:01:00 (formatted as time)

Regards

Davy
Pete_UK wrote:
> Try this:
>
> =IF(MOD(A2,1)<$C$1,"TRUE","FALSE")
>
> assuming your date/time is in A2. If it is in the other cell, try this:
>
> =IF(A2<MOD($C$1,1),"TRUE","FALSE")
>
> Hope this helps.
>
> Pete
>
> david-(E-Mail Removed) wrote:
> > Hi,
> >
> > I'm stuck on a comarison of times problem.
> >
> > My time column is formatted as "dd/mm/yyyy hh:mm:ss" although the
> > cell is formatted as hh:mm:ss
> >
> > I'd like a comparison to say if the time is less than say 14:00 then
> > TRUE else FALSE but a simple IF (A2<$C$1,"TRUE","FALSE") doesn't work.
> >
> > cell C1 is 14:00:00 formatted as hh:mm:ss
> >
> > A simple time subtraction works OK ie A2-C1
> >
> > If I could get rid of the DATE part of the field then the comparison
> > works OK. Trying a RIGHT function to just put the time part in a column
> > by itself doesn't work.
> >
> > Any ideas, as I'm stuck.
> >
> > regards
> >
> > Davy


 
Reply With Quote
 
david-witts@lycos.co.uk
Guest
Posts: n/a
 
      12th Jul 2006
Genius, thanks

this had me completely stuck. If you've got the time could you tell
me why it works?


Cell A2=30/11/1999 15:01:00

MOD(A2,1)=15:01:00 (formatted as time)

Regards

Davy
Pete_UK wrote:
> Try this:
>
> =IF(MOD(A2,1)<$C$1,"TRUE","FALSE")
>
> assuming your date/time is in A2. If it is in the other cell, try this:
>
> =IF(A2<MOD($C$1,1),"TRUE","FALSE")
>
> Hope this helps.
>
> Pete
>
> david-(E-Mail Removed) wrote:
> > Hi,
> >
> > I'm stuck on a comarison of times problem.
> >
> > My time column is formatted as "dd/mm/yyyy hh:mm:ss" although the
> > cell is formatted as hh:mm:ss
> >
> > I'd like a comparison to say if the time is less than say 14:00 then
> > TRUE else FALSE but a simple IF (A2<$C$1,"TRUE","FALSE") doesn't work.
> >
> > cell C1 is 14:00:00 formatted as hh:mm:ss
> >
> > A simple time subtraction works OK ie A2-C1
> >
> > If I could get rid of the DATE part of the field then the comparison
> > works OK. Trying a RIGHT function to just put the time part in a column
> > by itself doesn't work.
> >
> > Any ideas, as I'm stuck.
> >
> > regards
> >
> > Davy


 
Reply With Quote
 
Pete_UK
Guest
Posts: n/a
 
      12th Jul 2006
Davy,

dates are stored internally by Excel as integers - the number of
elapsed days from some reference date (1st Jan 1900). Times are stored
internally as fractions of a 24-hour day, so that 6:00:00 is actually
stored as 0.25 (quarter of a day). So, dates and times can be added
together and the whole number part represents the date and the
fractional part is the time.

The MOD( ) function gives the remainder after division, so MOD(A1,1)
will give just the time part of a date/time value in A1. Alternatively,
INT(A1) would give just the date part.

Hope this helps, and I'm glad you got it to work.

Pete

david-(E-Mail Removed) wrote:
> Genius, thanks
>
> this had me completely stuck. If you've got the time could you tell
> me why it works?
>
>
> Cell A2=30/11/1999 15:01:00
>
> MOD(A2,1)=15:01:00 (formatted as time)
>
> Regards
>
> Davy
> Pete_UK wrote:
> > Try this:
> >
> > =IF(MOD(A2,1)<$C$1,"TRUE","FALSE")
> >
> > assuming your date/time is in A2. If it is in the other cell, try this:
> >
> > =IF(A2<MOD($C$1,1),"TRUE","FALSE")
> >
> > Hope this helps.
> >
> > Pete
> >
> > david-(E-Mail Removed) wrote:
> > > Hi,
> > >
> > > I'm stuck on a comarison of times problem.
> > >
> > > My time column is formatted as "dd/mm/yyyy hh:mm:ss" although the
> > > cell is formatted as hh:mm:ss
> > >
> > > I'd like a comparison to say if the time is less than say 14:00 then
> > > TRUE else FALSE but a simple IF (A2<$C$1,"TRUE","FALSE") doesn't work.
> > >
> > > cell C1 is 14:00:00 formatted as hh:mm:ss
> > >
> > > A simple time subtraction works OK ie A2-C1
> > >
> > > If I could get rid of the DATE part of the field then the comparison
> > > works OK. Trying a RIGHT function to just put the time part in a column
> > > by itself doesn't work.
> > >
> > > Any ideas, as I'm stuck.
> > >
> > > regards
> > >
> > > Davy


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to compare times - only need AM/PM gweasel Microsoft Access Forms 2 9th Apr 2007 04:16 PM
How do I compare two times to see if one is "late" or "on time"? =?Utf-8?B?QXVkaXRvckdpcmw=?= Microsoft Excel Worksheet Functions 1 27th Jul 2005 05:59 PM
EXCEL - I need to compare times to the hundredth of a second =?Utf-8?B?c2F2ZXJ5NDIy?= Microsoft Excel Setup 1 20th Jun 2005 06:32 PM
Compare Times =?Utf-8?B?Y2FybA==?= Microsoft Excel Worksheet Functions 2 3rd Dec 2004 06:27 PM
Compare file times across TimeZones ? Sunit Joshi Microsoft C# .NET 3 18th Jun 2004 04:10 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:40 PM.