Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Need SQL Script to Convert Seconds to HHMM

Author  Topic 

LOgle0917
Starting Member

9 Posts

Posted - 2008-02-13 : 13:50:06
For example my time shows as 780 (seconds) I need the time to display as 1:00 pm:


This is my field information.

From NUMBER (10) Starting Time of Appt

(in minutes from midnight, ex: 540 = 9 AM)


Thanks!
Lisa

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2008-02-13 : 14:09:39
moved from script library. script library is meant for posting working scripts.

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
SSMS Add-in that does a few things: www.ssmstoolspack.com <- new version out
Go to Top of Page

LOgle0917
Starting Member

9 Posts

Posted - 2008-02-13 : 14:12:49
Which Forum did you move this to?

Thanks!
Lisa
Go to Top of Page

jhocutt
Constraint Violating Yak Guru

385 Posts

Posted - 2008-02-13 : 14:21:05
>>>For example my time shows as 780 (seconds) I need the time to display as 1:00 pm:
780 seconds would be 13 minutes IE 00:13 after the start time (I assume midnight)
If you mean minutes then

declare @min integer
select @min=780
select
MINUTES=@min,
HHMM_TIME=
right('00'+Cast( (@min-(@min%60))/60 as varchar),2)
+':'+
right('00'+Cast(@min%60 as varchar),2)


"God does not play dice" -- Albert Einstein
"Not only does God play dice, but he sometimes throws them where they cannot be seen."
-- Stephen Hawking
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2008-02-13 : 14:24:41
i moved it to SQL Server 2005 Forums -> Transact-SQL (2005)

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
SSMS Add-in that does a few things: www.ssmstoolspack.com <- new version out
Go to Top of Page
   

- Advertisement -