Solved

How do I convert the number in seconds to minutes and seconds for displaying in string

Posted on 2013-06-11
2
247 Views
Last Modified: 2013-06-11
I'm totalling up columns in a GridView to display in the footer, however, the column is the Call Duration of a phone call and the overall total will be in seconds.  However, I need to display it as hours:minutes:seconds as sometimes the total will be > 60 seconds and maybe even more than 3600 seconds. Is there an easy way to do this using myStringSeconds.ToString(xxxxx)??
0
Comment
Question by:Lorna70
2 Comments
 
LVL 42

Accepted Solution

by:
sedgwick earned 250 total points
ID: 39237536
TimeSpan t = TimeSpan.FromSeconds(totalSeconds);

string answer = string.Format("{0:D2}h:{1:D2}m:{2:D2}s:{3:D3}ms", 
    			t.Hours, 
    			t.Minutes, 
    			t.Seconds, 
    			t.Milliseconds);

Open in new window

from http://stackoverflow.com/questions/463642/what-is-the-best-way-to-convert-seconds-into-hourminutessecondsmilliseconds
0
 
LVL 51

Expert Comment

by:Julian Hansen
ID: 39237552
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

758 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