Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default Rounding Time down

Hi all

Require help with the best way to structure a Script to round down time to
the nearest even 30 mins.

eg
10:15 = 10:00
14:45 = 14:30
etc.

Though
10:00 would still = 10:00 and
14:30 would still = 14:30

The time is always recorded in 15 min increments, but for this specific
report required, I have to covert it to the 30 min format.

I figured VB code would be the better option as an IF() statement would
possibly be a tad too long.

TIA
Mick


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 138
Default Rounding Time down

On Feb 10, 9:05*am, "Vacuum Sealed" wrote:
Hi all

Require help with the best way to structure a Script to round down time to
the nearest even 30 mins.

eg
10:15 = 10:00
14:45 = 14:30
etc.

Though
10:00 would still = 10:00 and
14:30 would still = 14:30

The time is always recorded in 15 min increments, but for this specific
report required, I have to covert it to the 30 min format.

I figured VB code would be the better option as an IF() statement would
possibly be a tad too long.

TIA
Mick


On the basis that your time is always recorded in 15 minute
increments:

=IF(MINUTE(A1)=15,A1-0.0104166666666666,IF(MINUTE(A1)=45,A1-0.0104166666666666,A1))

assuming your input time is in cell A1. You may have to format the
target cell as hh:mm:ss and the 15 minute constant (0.01041 .....)
could be stored in another cell (eg A2) such that the if statement
simplifies to

=IF(MINUTE(A1)=15,A1-$A$2,IF(MINUTE(A1)=45,A1-$A$2,A1))

A.
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 138
Default Rounding Time down

On Feb 10, 9:23*am, Alan wrote:
On Feb 10, 9:05*am, "Vacuum Sealed" wrote:





Hi all


Require help with the best way to structure a Script to round down time to
the nearest even 30 mins.


eg
10:15 = 10:00
14:45 = 14:30
etc.


Though
10:00 would still = 10:00 and
14:30 would still = 14:30


The time is always recorded in 15 min increments, but for this specific
report required, I have to covert it to the 30 min format.


I figured VB code would be the better option as an IF() statement would
possibly be a tad too long.


TIA
Mick


On the basis that your time is always recorded in 15 minute
increments:

=IF(MINUTE(A1)=15,A1-0.0104166666666666,IF(MINUTE(A1)=45,A1-0.0104166666666*666,A1))

assuming your input time is in cell A1. You may have to format the
target cell as hh:mm:ss and the 15 minute constant (0.01041 .....)
could be stored in another cell (eg A2) such that the if statement
simplifies to

=IF(MINUTE(A1)=15,A1-$A$2,IF(MINUTE(A1)=45,A1-$A$2,A1))

A.- Hide quoted text -

- Show quoted text -


Alternatively:

=A1-$A$2*OR(MINUTE(A1)=15,MINUTE(A1)=45)

Same input cell addresses as in previous response.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default Rounding Time down

Alan

Thank you so much

That works magnificantly.

Cheers
Mick


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,059
Default Rounding Time down

On Feb 10, 1:05*am, "Vacuum Sealed" wrote:
Require help with the best way to structure a Script
to round down time to the nearest even 30 mins.
eg
10:15 = 10:00
14:45 = 14:30
etc.
Though
10:00 would still = 10:00 and
14:30 would still = 14:30
The time is always recorded in 15 min increments


It might help to know that numeric time is stored as a fraction of a
day. 1 hour is 1/24; 1 minute is 1/1440 (1440 = 24*60); and 1 second
is 1/86400 (86400 = 24*60*60).

So rather than taking advantage of the special assumption that time is
entered in 15-min increments, the more general way to round down to 30-
min increments is:

=FLOOR(A1*1440,30)/1440

formatted in the form you wish.


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
Rounding off time RD Excel Worksheet Functions 5 July 10th 09 08:15 PM
Rounding time Learning Excel Excel Discussion (Misc queries) 2 November 17th 07 03:29 PM
Time and rounding LINDA New Users to Excel 3 November 23rd 06 09:46 AM
Rounding Time Darts Excel Discussion (Misc queries) 11 March 23rd 06 10:55 PM
Rounding Time Tom Ogilvy Excel Programming 0 August 30th 04 05:57 PM


All times are GMT +1. The time now is 06:45 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"