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

  • Thread starter Thread starter Bogdan
  • Start date Start date
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
 
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
 
Back
Top