Unix Technical Forum

Time Function?

This is a discussion on Time Function? within the SQL Server forums, part of the Microsoft SQL Server category; --> Hi How can I convert integer to time . Ex: number = 91 Result = 1h 31m Something like ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-29-2008, 05:48 AM
Dishan Fernando
 
Posts: n/a
Default Time Function?

Hi
How can I convert integer to time .

Ex:
number = 91
Result = 1h 31m

Something like that. I want to do it in DATETIME Function!
Thanks
Dishan

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-29-2008, 05:48 AM
David Portas
 
Posts: n/a
Default Re: Time Function?

This seems to be about formatting a value for display so I suggest you do
that client-side rather than in the database. SQL Server doesn't have a TIME
datatype so your time will have to include a date as well. You can just
ignore the date unless the time value exceeds 86400 (24 hrs) in which case
your "time" value will then no longer make sense without a value in days as
well. I'll assume that isn't a problem for you. Try:

DECLARE @i INTEGER
SET @i = 91
SELECT DATEADD(mi,@i,0)

--
David Portas
SQL Server MVP
--


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-29-2008, 05:49 AM
SQLANG
 
Posts: n/a
Default Re: Time Function?

DECLARE @mint INTEGER
SET @mint = 91
SELECT convert(varchar(5),DATEADD(mi,@mint,0),114)
Got it down to h:mi truncating date


RA
MCDBA

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 08:23 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com