Rounding a Date

I'm needing to round a date based on the timestamp within the field.  Right now, I have say "12/08/17 16:42:05" in a given cell.  I need to round this date to either 12/08/17 or 12/09/17, based on the time.  So if an order came in at say 3pm (15:00:00), I need the date to round to the next day, since that's after hours. Make sense?
lindemrmAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bill PrewCommented:
You should just be able to use ROUND(), so if the date is in A1 then use this (and format the result column as just date, no time if you don't want to see the 00:00:00 time on the end):

=ROUND(A1,0)


»bp
0
lindemrmAuthor Commented:
That doesn't allow me to select a time at which I want the date to round up.
0
Bill PrewCommented:
Okay, so what would the cutoff time be?


»bp
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

lindemrmAuthor Commented:
In this case, I'm needing to set the cutoff time to 15:00:00 Eastern.
0
Bill PrewCommented:
Okay, give this a try:

=IF(TIME(HOUR(A1),MINUTE(A1),SECOND(A1))>=TIME(15,0,0),DATE(YEAR(A1),MONTH(A1),DAY(A1))+1,DATE(YEAR(A1),MONTH(A1),DAY(A1)))

Open in new window



»bp
0
Bill PrewCommented:
Or more compact:

=TRUNC(A1)+IF(TIME(HOUR(A1),MINUTE(A1),SECOND(A1))>=TIME(15,0,0),1,0)

Open in new window


»bp
0
Wayne Taylor (webtubbs)Commented:
=IF(MOD(A1,1)>TIME(15,0,0), ROUNDUP(A1, 0), ROUNDDOWN(A1,0))
0
Bill PrewCommented:
Can I steal the MOD() Wayne, please... :-)

So that could then be in my approach:

=TRUNC(A1)+IF(MOD(A1,1)>=TIME(15,0,0),1,0)

Open in new window


»bp
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
lindemrmAuthor Commented:
Thanks Guys!
0
Wayne Taylor (webtubbs)Commented:
Just realised you could make it even smaller like this...

=INT(A1+1-TIME(15,0,0))
1
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.