Solved

Converting seconds to m.ss

Posted on 2003-11-22
2
188 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses
Course of the Month10 days, 23 hours left to enroll

631 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