Comparing current time to the time in the past and the future

Brennivin

New Member
Joined
Mar 27, 2013
Messages
7
Hi,

It is currently 11.40 AM. When I evaluate
Code:
?Now() > TimeSerial(11,30,0)

I get True.

However, when I evaluate
Code:
?Now() < TimeSerial(11,50,0)

I get False.

Why is this?
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Now() is the current system date and time.
Try using Now()-Date > TimeSerial(11,30,0)
 
Upvote 0
Now() is the current system date and time.
Try using Now()-Date > TimeSerial(11,30,0)

Now() > TimeSerial(11,30,0) is True -- it evaluates correctly. There's something about the less than condition that doesn't evaluate correctly.
 
Upvote 0
Because NOW() is DATE + TIME, while TIMESERIAL(...) is just time.
Dates are Whole numbers incrimenting by 1 since Jan 1 1900
Jan 1 1900 = 1
Jan 2 1900 = 2
etc
Mar 27 2013 = 41360

TIMES are Decimal Numbers (Fractions of 1)
6AM = 0.25
NOON = 0.5
6PM = 0.75

DATE + TIME = Whole Number + Decimal.
So Mar 13th 2013 at 6PM = 41360.75

Put =NOW() in 1 cell and =TIME(11,30,0) in another.
And format those cells as a number with 6 or more decimals.
You'll see the difference.
 
Last edited:
Upvote 0
That should have read Mar 27th 2013 at 6PM

Hi Jonmo, thanks for your response, but my issue is that the greater than comparison works, but the lesser than comparison doesn't, when I'm comparing Now() against TimeSerial. Sorry I should've been more specific in my original post.
 
Upvote 0
Hi Jonmo, thanks for your response, but my issue is that the greater than comparison works, but the lesser than comparison doesn't, when I'm comparing Now() against TimeSerial. Sorry I should've been more specific in my original post.

No, you expressed your concern quite clearly and it was understood.

You're not understanding the answer.


NOW() will ALWAYS be greater than any value returned by TIMESERIAL
Because NOW is equal to TODAY(41360)+CurrentTime(a decimal number less than 0)
But TIMESERIAL is a number less than 0 (a fraction of 1 day)


Here's some results given from my immediate window

?Now()
3/27/2013 1:10:58 PM
?Timeserial(15,30,0)
3:30:00 PM
?cdbl(now())
41360.549525463
?Cdbl(timeserial(11,30,0))
0.479166666666667
?now() > timeserial(15,30,00)
True
 
Last edited:
Upvote 0
No, you expressed your concern quite clearly and it was understood.

You're not understanding the answer.


NOW() will ALWAYS be greater than any value returned by TIMESERIAL
Because NOW is equal to TODAY(41360)+CurrentTime(a decimal number less than 0)
But TIMESERIAL is a number less than 0 (a fraction of 1 day)


Here's some results given from my immediate window

?Now()
3/27/2013 1:10:58 PM
?Timeserial(15,30,0)
3:30:00 PM
?cdbl(now())
41360.549525463
?Cdbl(timeserial(11,30,0))
0.479166666666667
?now() > timeserial(15,30,00)
True


Ohhh, I get it. Awesome. Thanks a lot!
 
Upvote 0

Forum statistics

Threads
1,203,317
Messages
6,054,709
Members
444,742
Latest member
jmartin9247

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top