View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Alan Alan is offline
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.