MrExcel Message Board

Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old May 3rd, 2002, 07:17 PM   #1
theclaah
New Member
 
Join Date: Apr 2002
Posts: 29
Default

How would I round time to the quarter hour?Such as if the time is 8:20 AM I would want to roundDown to 8:15 or in some case i might need to roundUp to 8:30.
theclaah is offline   Reply With Quote
Old May 3rd, 2002, 07:39 PM   #2
Tom Urtis
MrExcel MVP
 
Tom Urtis's Avatar
 
Join Date: Feb 2002
Location: San Francisco, California USA
Posts: 10,388
Default

To round down to the quarter hour, so 6:26 = 6:15:
=FLOOR(A1,15/(60*24))
Or
=FLOOR(A1,0.0104166666666667)

To round up so that 6:26 = 6:30:
=CEILING(A1,15/(60*24))
Or
=CEILING(A1,0.0104166666666667)

Note, you can substitute
15/(60*24)
with the constant
0.0104166666666667

Substitute A1 for your cell(s) of interest.
__________________
Tom Urtis
Microsoft MVP - Excel
Tom Urtis is offline   Reply With Quote
Old May 3rd, 2002, 07:42 PM   #3
Steve Hartman
Board Regular
 
Steve Hartman's Avatar
 
Join Date: Feb 2002
Location: Houston,Texas
Posts: 418
Default

Use =MROUND(A1,0.0104166666666667) where your date is in A1. This will round up OR down to the NEAREST quarter hour in one step.



[ This Message was edited by: Steve Hartman on 2002-05-03 18:45 ]
Steve Hartman is offline   Reply With Quote
Old May 3rd, 2002, 08:11 PM   #4
Rocky E
Board Regular
 
Join Date: Feb 2002
Location: North Alabama, USA
Posts: 105
Default

I am not totally clear on your application, but a simple compound IF will return one result that can give a quarter hour integer. For example if A1 contains the time, formated as time. You can get the number of minutes as number in B1 with =MINUTE(A1). The your quarter hour forumal would be
=IF(B1<15,0,IF(B1<30,15,IF(B1<45,30,45)))

If you require help to merge the result just let me know.


_________________
Hope this helps!

Rocky

"Be not the first by whom the New are try'd,
Nor yet the last to lay the Old aside."
Alexander Pope (1688-1744).

[ This Message was edited by: Rocky E on 2002-05-03 19:18 ]
Rocky E is offline   Reply With Quote
Old May 3rd, 2002, 09:41 PM   #5
Yogi Anand
MrExcel MVP
 
Join Date: Mar 2002
Location: Michigan USA
Posts: 11,452
Default

Quote:
On 2002-05-03 18:17, theclaah wrote:
How would I round time to the quarter hour?Such as if the time is 8:20 AM I would want to roundDown to 8:15 or in some case i might need to roundUp to 8:30.
You can use the MROUND function to round to the nearest 15th minute (nearest quarter hour) ... use

=MROUND("8:20 AM","0:15")

If you must round up to the next quarter hour then use the following modification:

=MROUND(IF(MOD(A2,"0:7.5")>0,A2+"0:7.5",A2),"0:15")




_________________
Yogi Anand

Edit: Deleted inactive website from hardcoded signature

[ This Message was edited by: Yogi Anand on 2003-01-19 13:24 ]
Yogi Anand is offline   Reply With Quote
Old May 4th, 2002, 04:58 PM   #6
Steve Hartman
Board Regular
 
Steve Hartman's Avatar
 
Join Date: Feb 2002
Location: Houston,Texas
Posts: 418
Default

Quote:
On 2002-05-03 20:41, Yogi Anand wrote:
Quote:
On 2002-05-03 18:17, theclaah wrote:
How would I round time to the quarter hour?Such as if the time is 8:20 AM I would want to roundDown to 8:15 or in some case i might need to roundUp to 8:30.
You can use the MROUND function to round to the nearest 15th minute (nearest quarter hour) ... use

=MROUND("8:20 AM","0:15")

If you must round up to the next quarter hour then use the following modification:

=MROUND(IF(MOD(A2,"0:7.5")>0,A2+"0:7.5",A2),"0:15")




_________________
Yogi Anand
ANAND Enterprises
http://www.handtech.com/anand yogia@hotmail.com

[ This Message was edited by: Yogi Anand on 2002-05-03 20:46 ]
Yogi, MROUND rounds up OR down as it is without the IF and MOD.
Steve Hartman is offline   Reply With Quote
Old May 6th, 2002, 10:34 AM   #7
Yogi Anand
MrExcel MVP
 
Join Date: Mar 2002
Location: Michigan USA
Posts: 11,452
Default

Quote:
On 2002-05-04 15:58, Steve Hartman wrote:
Quote:
On 2002-05-03 20:41, Yogi Anand wrote:
Quote:
On 2002-05-03 18:17, theclaah wrote:
How would I round time to the quarter hour?Such as if the time is 8:20 AM I would want to roundDown to 8:15 or in some case i might need to roundUp to 8:30.
You can use the MROUND function to round to the nearest 15th minute (nearest quarter hour) ... use

=MROUND("8:20 AM","0:15")

If you must round up to the next quarter hour then use the following modification:

=MROUND(IF(MOD(A2,"0:7.5")>0,A2+"0:7.5",A2),"0:15")




_________________
Yogi Anand
2002-05-03 20:46 ]
Yogi, MROUND rounds up OR down as it is without the IF and MOD.
Hi Steve:
MROUND rounds up, away from zero, if the remainder of dividing number by multiple is greater than or equal to half the value of multiple.
So, my second formula which should have correctly read as:

=MROUND(IF(MOD(A2,"0:7:30")>0,A2+"0:7:30",A2),"0:15")

is provided to force rounding up to the next (not the nearest quarter hour ... example:

=MROUND("8:22:00",0:15:00) would produce 8:15

but=MROUND(IF(MOD("8:22:00","0:7:30")>0,"8:22:00"+"0:7:30","8:22:00"),"0:15") would produce 8:30

Regards!

Yogi Anand




[ This Message was edited by: Yogi Anand on 2003-01-19 18:38 ]
Yogi Anand is offline   Reply With Quote
Old May 6th, 2002, 11:23 AM   #8
Steve Hartman
Board Regular
 
Steve Hartman's Avatar
 
Join Date: Feb 2002
Location: Houston,Texas
Posts: 418
Default

Directly from the help file:
Quote:
MROUND
See Also

Returns a number rounded to the desired multiple.
Try this for yourself and see:

In cell A1 put any positive number
In cell A2 put 5
In cell A3 put =MROUND(A1,A2)

Now change your number in A1 and see what you get in A3.

27 MROUNDED (to coin a term) to the nearest 5 is 25.
28 MROUNDED to the nearest 5 is 30.
27.4 MROUNDED to the nearest 5 is 25.
27.5 MROUNDED to the nearest 5 is 30, which is what the part of the help file you quoted is talking about.
Steve Hartman is offline   Reply With Quote
Old May 6th, 2002, 11:50 AM   #9
Steve Hartman
Board Regular
 
Steve Hartman's Avatar
 
Join Date: Feb 2002
Location: Houston,Texas
Posts: 418
Default

theclaah,

Quote:
On 2002-05-03 18:17, theclaah wrote:
How would I round time to the quarter hour?Such as if the time is 8:20 AM I would want to roundDown to 8:15 or in some case i might need to roundUp to 8:30.
Are you saying sometimes you would want to round 8:20 to 8:15 and sometimes you would want to round 8:20 to 8:30? If so how do you determine when to do which?

[ This Message was edited by: Steve Hartman on 2002-05-06 10:55 ]
Steve Hartman is offline   Reply With Quote
Old May 24th, 2002, 12:12 AM   #10
gareth
Board Regular
 
Join Date: Apr 2002
Location: Cape Town,South Africa
Posts: 234
Default

The claah writes :
How would I round time to the quarter hour?Such as if the time is 8:20 AM I would want to roundDown to 8:15 or in some case i might need to roundUp to 8:30.
======================

CLAAH

Are you busy with a timesheet for wages or salary,and you want to work out the time worked per employee ? Email me please because I have a formula just for that sort of thing.Dont worry I will share it with the board when I am done. garethl@ij.co.za
__________________
Regards
Gareth
Visit The Excel Maniacs :<>: Have a Chat! :<>: Free Stuff!
gareth is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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 On

Forum Jump


All times are GMT -4. The time now is 02:34 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
All contents Copyright 1998-2012 by MrExcel Consulting.
diabetic desserts recipes recipes Diabetic Soups Holiday Pizza Recipes Popcorn Recipes Recipes For Microwave Pasta Recipes Casserole Recipes Chili Recipes Curry Recipes Crockpot Recipes Apples Recipes Bread Recipes Vegetarian Recipes Vegetable recipes Desserts Recipes Appetizers Ethnic Recipes Meat Dishes Barbecue Recipes Sauces Recipes Marinade Recipes Low Fat Recipes Frugal Gourmet Kitchen Classics Recipes On The Grill Cook Books Seafood Recipes Cajun Recipes Breads Low Fat Low Fat Breads Bread Machine Recipes Yeast Breads Quick Breads Fat Free Vegetarian Salad Recipes Eggplant Recipes Radish Recipes Tomato Recipes Jalapeno Recipes Potato Recipes Lettuce Recipes Cabbage Recipes Beans Ambrosia Recipes Biscotti Recipes Desserts Low Fat Cookie Recipes Cheesecake Recipes Cake Recipes Pie Recipes Muffin Recipes Custard Recipes Best Appetizers Appetizers Low Fat Salsa Recipes Dip Recipes International Recipes Afghan Recipes Alaska Recipes French Recipes German Recipes Greek Recipes Italian Recipes Spanish Recipes Thai Recipes Korean Recipes Chinese Recipes Mexican Recipes Indian Recipes Beef Recipes Pork Pork & Ham Pork Butts Pork Chop Recipes Pork Ribs Rulled Pork Poultry Recipes Stews Recipes Ground Beef Barbecue Grill Barbecue Smoker All Purpose Sauce BBQ Sauce Barbecue Sauce Carolina BBQ Sauce Pickle Recipes Marinades Smoking Low Fat Appetizers & Dips Low Fat Breakfast Low Fat Cakes Low Fat Cheesecakes Low Fat Cookies Low Fat Desserts Low Fat Fish & Seafood Low Fat Meats Low Fat Pasta Low Fat Pies Low Fat Salads Low Fat Sandwiches Low Fat Sauces & Condiments Low Fat Sides Low Fat Soups Low Fat Vegetarian Baker's Dozen Taste of Home Recipe Book Bon Appetit Cookbook Blacktie Cookbook Buster Cook Book Cookbook USA Cook Book Cook Book Sara's Cookbook Sara's Cookbook Appetizers and Dips Poultry recipes Diabetic recipes Holiday recipes Miscellaneous recipes 110 recipes 1986 Usenet cookbook 2900 recipes Cyberrealm recipes Great sysops of world Specialty recipes Ceideburg recipes Cheese recipes Chili recipes Fruits recipes Garlic recipes Great chefs of NY Londontowne recipes Raisins recipes Recipes for kids US Food Vegetarian recipes Bread recipes Drinks Meat Dishes Brisket recipes Caribou recipes Chicken recipes Filet mignons recipes Pork recipes Swordfish recipes Turkey recipes Pasta recipes Uncategorized recipes Ethnic recipes Canada recipes English recipes Ethiopia recipes Germany recipes Greece recipes Mexican recipes Philippines recipes Welsh recipes Microwave recipes Soups recipes Vegetable recipes Asparagus recipes Barley recipes Brown rice recipes Lentil recipes Mushrooms recipes Salads recipes Wild rice Desserts recipes Cakes recipes Chocolate recipes Cookies recipes Ice cream recipes