Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 425
Default round time in column to nearest half hour

I am uploading data, and in column A it post the times like this:

01.31.06
02.00.06
02.31.08
03.00.05
03.31.06
04.00.23
04.31.15
05.00.11
05.31.12
06.00.07

I would like to insert code that would round each time DOWN to the
half hour and then remove the seconds.

01:30
02:00
02:30
03:00
03:30
04:00
04:30
05:00
05:30
06:00

any suggestions?
thanx
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,202
Default round time in column to nearest half hour

I think this will do what you want....

=ROUNDDOWN(24*SUBSTITUTE(A1,".",":"),1)/24

Rick


"J.W. Aldridge" wrote in message
...
I am uploading data, and in column A it post the times like this:

01.31.06
02.00.06
02.31.08
03.00.05
03.31.06
04.00.23
04.31.15
05.00.11
05.31.12
06.00.07

I would like to insert code that would round each time DOWN to the
half hour and then remove the seconds.

01:30
02:00
02:30
03:00
03:30
04:00
04:30
05:00
05:30
06:00

any suggestions?
thanx


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,202
Default round time in column to nearest half hour

Sorry, I just found out my formula doesn't work in the general case.

Rick


"Rick Rothstein (MVP - VB)" wrote in
message ...
I think this will do what you want....

=ROUNDDOWN(24*SUBSTITUTE(A1,".",":"),1)/24

Rick


"J.W. Aldridge" wrote in message
...
I am uploading data, and in column A it post the times like this:

01.31.06
02.00.06
02.31.08
03.00.05
03.31.06
04.00.23
04.31.15
05.00.11
05.31.12
06.00.07

I would like to insert code that would round each time DOWN to the
half hour and then remove the seconds.

01:30
02:00
02:30
03:00
03:30
04:00
04:30
05:00
05:30
06:00

any suggestions?
thanx



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default round time in column to nearest half hour

=TIME(LEFT(A1,2),ROUND(MID(A1,4,2)/30,0)*30,0)

--
---
HTH

Bob

__________________________________________
UK Cambridge XL Users Conference 29-30 Nov
http://www.exceluserconference.com/UKEUC.html

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"J.W. Aldridge" wrote in message
...
I am uploading data, and in column A it post the times like this:

01.31.06
02.00.06
02.31.08
03.00.05
03.31.06
04.00.23
04.31.15
05.00.11
05.31.12
06.00.07

I would like to insert code that would round each time DOWN to the
half hour and then remove the seconds.

01:30
02:00
02:30
03:00
03:30
04:00
04:30
05:00
05:30
06:00

any suggestions?
thanx



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,202
Default round time in column to nearest half hour

Sorry, I just found out my formula doesn't work in the general case.

Rick

"Bob Phillips" wrote in message
...
=TIME(LEFT(A1,2),ROUND(MID(A1,4,2)/30,0)*30,0)

--
---
HTH

Bob

__________________________________________
UK Cambridge XL Users Conference 29-30 Nov
http://www.exceluserconference.com/UKEUC.html

(there's no email, no snail mail, but somewhere should be gmail in my
addy)



"J.W. Aldridge" wrote in message
...
I am uploading data, and in column A it post the times like this:

01.31.06
02.00.06
02.31.08
03.00.05
03.31.06
04.00.23
04.31.15
05.00.11
05.31.12
06.00.07

I would like to insert code that would round each time DOWN to the
half hour and then remove the seconds.

01:30
02:00
02:30
03:00
03:30
04:00
04:30
05:00
05:30
06:00

any suggestions?
thanx






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,202
Default round time in column to nearest half hour

I didn't mean to post this to your message... sorry.

Rick


"Rick Rothstein (MVP - VB)" wrote in
message ...
Sorry, I just found out my formula doesn't work in the general case.

Rick

"Bob Phillips" wrote in message
...
=TIME(LEFT(A1,2),ROUND(MID(A1,4,2)/30,0)*30,0)

--
---
HTH

Bob

__________________________________________
UK Cambridge XL Users Conference 29-30 Nov
http://www.exceluserconference.com/UKEUC.html

(there's no email, no snail mail, but somewhere should be gmail in my
addy)



"J.W. Aldridge" wrote in message
...
I am uploading data, and in column A it post the times like this:

01.31.06
02.00.06
02.31.08
03.00.05
03.31.06
04.00.23
04.31.15
05.00.11
05.31.12
06.00.07

I would like to insert code that would round each time DOWN to the
half hour and then remove the seconds.

01:30
02:00
02:30
03:00
03:30
04:00
04:30
05:00
05:30
06:00

any suggestions?
thanx





  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 425
Default round time in column to nearest half hour

how would i do this in vba...?

Want to implement this in the code after it downloads.


thanx


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,202
Default round time in column to nearest half hour

how would i do this in vba...?

Want to implement this in the code after it downloads.


You should be able to use this function... simply pass in each time string
you downloaded and a rounded down time value will be returned...

Function RoundedTime(TimeIn As String) As Date
Dim DecimalTime As Double
DecimalTime = 24 * TimeSerial(Left(TimeIn, 2), _
Mid(TimeIn, 4, 2), Right(TimeIn, 2))
RoundedTime = (Int(DecimalTime) + Int(2 * (DecimalTime - _
Int(DecimalTime))) / 2) / 24
End Function


Rick

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,202
Default round time in column to nearest half hour

You need to change the ROUND function call to ROUNDDOWN... the OP asked for
the times to be rounded "down" to the half-hour.

=TIME(LEFT(A1,2),ROUNDDOWN(MID(A1,4,2)/30,0)*30,0)

Rick


"Bob Phillips" wrote in message
...
=TIME(LEFT(A1,2),ROUND(MID(A1,4,2)/30,0)*30,0)

--
---
HTH

Bob

__________________________________________
UK Cambridge XL Users Conference 29-30 Nov
http://www.exceluserconference.com/UKEUC.html

(there's no email, no snail mail, but somewhere should be gmail in my
addy)



"J.W. Aldridge" wrote in message
...
I am uploading data, and in column A it post the times like this:

01.31.06
02.00.06
02.31.08
03.00.05
03.31.06
04.00.23
04.31.15
05.00.11
05.31.12
06.00.07

I would like to insert code that would round each time DOWN to the
half hour and then remove the seconds.

01:30
02:00
02:30
03:00
03:30
04:00
04:30
05:00
05:30
06:00

any suggestions?
thanx




  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 176
Default round time in column to nearest half hour

A suggestion:
=CONCATENATE(LEFT(A1,2),":",MID(A1,4,2))
D-C Dave

"J.W. Aldridge" wrote:
I am uploading data, and in column A it post the times like this:
01.31.06
02.00.06
I would like to insert code that would round each time DOWN to the
half hour and then remove the seconds.
01:30
02:00
any suggestions?
thanx




  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default round time in column to nearest half hour

On Sat, 24 Nov 2007 09:42:23 -0800 (PST), "J.W. Aldridge"
wrote:

I am uploading data, and in column A it post the times like this:

01.31.06
02.00.06
02.31.08
03.00.05
03.31.06
04.00.23
04.31.15
05.00.11
05.31.12
06.00.07

I would like to insert code that would round each time DOWN to the
half hour and then remove the seconds.

01:30
02:00
02:30
03:00
03:30
04:00
04:30
05:00
05:30
06:00

any suggestions?
thanx


=FLOOR(LEFT(SUBSTITUTE(A1,".",":",1),5),30/1440)

or, as a VBA function:

=============================
Function RoundDown30(t) As Date
RoundDown30 = Left(Replace(t, ".", ":", 1, 1), 5)
RoundDown30 = Application.WorksheetFunction.Floor(RoundDown30, 30 / 1440)
End Function
======================
--ron
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
How do I round time down to the nearest half hour? KatJ Excel Worksheet Functions 4 April 3rd 23 07:32 PM
how do i round time to the nearest half a minute ALEX Excel Discussion (Misc queries) 3 September 25th 06 11:25 PM
How do I round time to the nearest quarter of an hour Meghan New Users to Excel 6 July 7th 06 06:36 PM
Need to round the time to the nearest quarter hour. Help John Excel Discussion (Misc queries) 1 February 11th 06 06:41 AM
To reformat a culculated date/time round-up to the nearest ½ hour Macgyver Goh Excel Programming 2 August 29th 04 03:23 PM


All times are GMT +1. The time now is 01:21 AM.

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"