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

Discussion in 'ASP .Net' started by Bogdan, Feb 19, 2010.

  1. Bogdan

    Bogdan Guest

    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
     
    Bogdan, Feb 19, 2010
    #1
    1. Advertising

  2. 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?

    Andrew
     
    Andrew Morton, Feb 22, 2010
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. tshad
    Replies:
    7
    Views:
    17,078
    tshad
    Mar 11, 2005
  2. 00_CP_D12
    Replies:
    3
    Views:
    8,981
    dilipv
    Feb 22, 2008
  3. Stu
    Replies:
    7
    Views:
    1,787
    Dave Thompson
    Mar 7, 2005
  4. Michael Tan
    Replies:
    32
    Views:
    1,022
    Ara.T.Howard
    Jul 21, 2005
  5. `p
    Replies:
    7
    Views:
    387
    Steve Litt
    Dec 14, 2005
Loading...

Share This Page