Home All Groups Group Topic Archive Search About

Convert int seconds to legable time

Author
2 Mar 2006 8:07 PM
Pat Brown
I have a field that holds the number of seconds from midnight.  I need to
take this int value and turn it into a legable time.  I also need to take
input in 12:00 format and change back to int seconds to store in the db.
Any suggestions?

Author
2 Mar 2006 8:17 PM
Roy Harvey
You need to read up on datediff and dateadd.

declare @secs bigint
set @secs = 12345

select dateadd(second, @secs, '2 March 2006')

------------------------------------------------------
2006-03-02 03:25:45.000

select datediff (second,  '2 March 2006', '2 March 2006 16:47:13')

-----------
      60433

Roy Harvey
Beacon Falls, CT


On Thu, 2 Mar 2006 12:07:27 -0800, Pat Brown
<PatBr***@discussions.microsoft.com> wrote:

Show quote
>I have a field that holds the number of seconds from midnight.  I need to
>take this int value and turn it into a legable time.  I also need to take
>input in 12:00 format and change back to int seconds to store in the db.
>Any suggestions?

AddThis Social Bookmark Button