Convert General Format To Time

dgrowe

Board Regular
Joined
Jun 10, 2004
Messages
75
I have some data being pulled in by a query program from an AS/400 system. Unfortunately the times I am pulling in are not in a numeric format. The numbers below represent actual times in 24-hour format (ex. 21:30, 2:13, 4:45, & 22:24). I would like to change them to a decimal time format (ex. 21.50, 2.22, 4.75, & 22.4).

213000
21300
44500
222400
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Format the cell to number and try this:

=TIME(IF(LEN(A25)=6,LEFT(A25,2),LEFT(A25,1)),IF(LEN(A25)=6,MID(A25,3,2),MID(A25,2,2)),RIGHT(A25,2))*24

Change A25 to appropriate cell. You may have to after inputting the formual change to number, but not sure.

Hope that helps.
Book1
ABCD
2521300021.50
26213002.22
27445004.75
2822240022.40
Sheet1
 
Upvote 0
Here is some code to automate this
Code:
Sub ConvertTime()
Dim cl As Range
For Each cl In Range("$A$2:$A" & Range("$A$65536").End(xlUp).Row)
cl = cl * 0.0001
cl = Evaluate("=dollarde(" & cl & ",60)")
Next cl
End Sub

Format cells as desired
Analysis ToolPak must be installed!!!

lenze
 
Upvote 0
Another formula possibility:

=TEXT(A1,"00\:00\:00")*24

Format as number with 2 decimal places.


<SCRIPT language=JavaScript src="<a href=" popup.js" colo puremis sun www.interq.or.jp http:></SCRIPT><CENTER><TABLE" target="_blank">
Excel Workbook
ABC
121300021.50
2213002.22
3445004.75
422240022.40
Sheet1


</CENTER>
 
Upvote 0

Forum statistics

Threads
1,214,879
Messages
6,122,065
Members
449,064
Latest member
scottdog129

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top