Apple Intelligence now features Image Playground, Genmoji, Writing Tools enhancements, seamless support for ChatGPT, and visual intelligence.

Apple Intelligence has also begun language expansion with localized English support for Australia, Canada, Ireland, New Zealand, South Africa, and the U.K. Learn more >

You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Convert minutes:seconds:milliseconds into a seconds:milliseconds value

Hi, I am trying to convert a value of time from reading as minute:seconds:milliseconds into a total display of seconds:milliseconds


For example xx.yy.zz into yy.zz where 01.17.72 would now be 77.72


I have tried playing around with just changing the cell format to a duration cell but the value is assuming that 01.17.72 means 1 hour 18 minutes and 12 seconds. Is there any way to even change this so that I can do it to multiple cells at once?





MacBook Pro 15", macOS 10.14

Posted on Apr 3, 2019 6:39 AM

Reply
7 replies

Apr 3, 2019 9:10 PM in response to Au79bydesign

Numbers can convert to duration with the displayed style of ss.mmm.


Where you have 01:34:08 do you mean 1 minute 34 seconds and 8 milliseconds? Or do you mean 1 minute 34 seconds and 80 milliseconds?


Assuming you mean 1 minute 34 seconds and 8 milliseconds and you will be working with the values in Numbers (i.e. you're not just trying to convert and then use elsewhere) then you can do this.


  1. Copy-paste the script below into Script Editor (in Application > Utilities)
  2. The first time make sure Script Editor.app and Numbers.app are listed and checked at System Preferences > Security & Privacy > Privacy > Accessibility.
  3. Select the cells in Numbers you want to convert to duration.
  4. Click the triangle 'run' button in Script Editor.
  5. Choose the Data Format pictured in the screenshot in the previous post (custom units sec and ms toggled on and style 00.000 selected)


As always, best to try this on a copy of your data first.


This should all take about a minute (no need to know AppleScript to use the script), and the results will be something like this:




You can work with these as duration values in Numbers or copy-paste elsewhere as needed. If by you meant 1 minute 34 seconds and 80 milliseconds post and will give you the necessary small adjustment to the script.

SG



The script (be sure to copy-paste everything in the box; some parts may scroll out of view to the right):


tell application "Numbers"
	tell front document's active sheet
		tell (first table whose selection range's class is range)
			repeat with c in (get selection range)'s cells
				set v to c's value
				set theDur to v's first word & "m " & v's second word & "s " & v's third word & "ms"
				set c's value to theDur
			end repeat
		end tell
	end tell
end tell






Apr 3, 2019 7:00 AM in response to Au79bydesign

You mention seconds:milliseconds in your header but have xx.yy.zz in the text.


Numbers won't recognize . as the separator. Numbers can display the : as the separator.


However, when you enter duration values you would type 1m 17s 72ms or 77s 72ms.


Once you have entered a value and Numbers recognizes it as a duration (by default right-aligned) then you can change the way it is displayed if you want:









SG


Apr 3, 2019 9:40 PM in response to Au79bydesign

If by 01:34:08 you meant 1 minute 34 seconds and 80 milliseconds the use this script instead. The other steps are the same, and should take a minute or so. It will give you something like this:



SG


tell application "Numbers"
	tell front document's active sheet
		tell (first table whose selection range's class is range)
			repeat with c in (get selection range)'s cells
				set v to c's value
				set min to v's first word
				set sec to v's second word
				set milsec to v's third word
				if milsec's length is 2 then
					set milsec to milsec & "0"
				end if
				set theDur to min & "m " & sec & "s " & milsec & "ms"
				set c's value to theDur
				set c's format to duration
			end repeat
		end tell
	end tell
end tell



Apr 4, 2019 6:06 AM in response to Au79bydesign

 Is there anyway I can change to milliseconds to only 2 decimal
 points instead of the full three


If you're using the duration values further in Numbers then I think the answer is "no, that would confuse Numbers." It might also confuse human readers, as milliseconds are of course thousands of a second. It's a little like saying whenever I write the Number 8 what I really mean is 80.


However, if you are you taking the values and using them outside Numbers, you could do something like this:




I explicitly formatted the cells in column C as Text using the Data Format dropdown. Then I selected the values converted by the script, typed command-c to copy to the clipboard, clicked in C2 and chose Edit > Paste and Match Style from the menu to paste as text. Then I used the formula to chop off the last character. If the value is in C2, the formula would be: =LEFT(C2,LEN(C2)−1). Those truncated text values can then be copy-pasted elsewhere outside Numbers.


SG

Apr 3, 2019 2:49 PM in response to SGIII

I have hundreds of fields like this so i don’t want to input manually, I just want to be able to copy and paste and apply a formula or change cell format to all of the fields. I just used find and replace to convert xx:yy::zz to xx.yy.zz and I still cannot get it to work. Using either semi colon or decimal didn’t make any difference.


Essentially I have hundreds of fields that are for example

01:34:08

01:15:80

02:06:35

and I would like to convert them to the following

94:08

75:80

126:35


is thus even possible in Numbers?

Convert minutes:seconds:milliseconds into a seconds:milliseconds value

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.