Solved

Converting seconds to m.ss

Posted on 2003-11-22
2
174 Views
Last Modified: 2010-05-01
Hi Experts,

I am working on a way of converting seconds to m.ss but all i can get is hh.mm.ss using:

VarSeconds = 313.069875
VarTime = Format(DateAdd("s", VarSeconds, "00:00:00"), "hh.mm.ss")

This returns the time 00.05.13, but i would like 5.13 to be returned.

Also if the time is for example 10 minutes it needs to return 10.00 and not 0.00


Any ideas??

Thanks
robbrownuk
0
Comment
Question by:robbrownuk
2 Comments
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 30 total points
ID: 9803746
Try this:

VarTime =  CStr(VarSeconds \ 60) & ":" & CStr(VarSeconds Mod 60)

Anthony
0
 
LVL 2

Author Comment

by:robbrownuk
ID: 9803854
That works great - just modified it a bit because 5 minutes was reading as 5:0 not 5:00.

Final Code:

VarTime = CStr(VarSeconds \ 60) & ":" & Format(CStr(VarSeconds Mod 60), "0#")


Thanks Anthony,

robbrownuk
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now