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

B

Bogdan

Hi,

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.

Thanks,
Bogdan
 
A

Andrew Morton

Mark said:
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?

Andrew
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top