Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Seconds from DB to hh:mm:ss in GridView. How to?

Thread Tools

Seconds from DB to hh:mm:ss in GridView. How to?

Posts: n/a

I have a db table with a column that stores duration in seconds. I need to
present this duration as hh:mm:ss in a gridview. I'm not quite sure where
the int to string conversion should take place. Should I attempt to do that
in a stored proc, business object, or another place?
An example would be very appreciated.


Reply With Quote
Andrew Morton
Posts: n/a
Mark Rae [MVP] wrote:
> Converting integral seconds into formatted times is simple enough:
> int intSeconds = 350;
> long lngTicksPerSecond = 10000000;
> DateTime dtmTest = new DateTime(intSeconds * lngTicksPerSecond);
> string strFormattedDate = dtmTest.ToString("HH:mm:ss");

Maybe TimeSpan.FromSeconds(n) would suit the OP better as they're
representing a duration rather than an absolute date?


Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
How to convert Seconds to X Hours Y Minutes Z Seconds? 00_CP_D12 ASP .Net 3 02-22-2008 10:37 AM
1. Ruby result: 101 seconds , 2. Java result:9.8 seconds, 3. Perl result:62 seconds Michael Tan Ruby 32 07-21-2005 03:23 PM
Convert seconds to minutes and seconds tshad ASP .Net 7 03-11-2005 11:27 PM
Converting seconds to (Days, Hours, Minutes, seconds) Stu C Programming 7 03-07-2005 08:44 AM