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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 convert minutes to time field
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

esthera
Flowing Fount of Yak Knowledge

1410 Posts

Posted - 08/20/2012 :  15:31:59  Show Profile  Reply with Quote
I have 2 datetime fields and when I do a datediff I get the amount in minutes

how can I convert the minutes fields to datetime so that for example 26 minutes will show as 1900-01-01 00:21

Lamprey
Flowing Fount of Yak Knowledge

4614 Posts

Posted - 08/20/2012 :  15:41:53  Show Profile  Reply with Quote
SELECT CONVERT(VARCHAR(16), DATEADD(MINUTE, 26 - 5, '1900-01-01 00:00:00'), 121)
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52326 Posts

Posted - 08/20/2012 :  17:11:07  Show Profile  Reply with Quote
quote:
Originally posted by esthera

I have 2 datetime fields and when I do a datediff I get the amount in minutes

how can I convert the minutes fields to datetime so that for example 26 minutes will show as 1900-01-01 00:21



make sure you read this

http://visakhm.blogspot.com/2012/07/generate-datetime-values-from-integers.html

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.04 seconds. Powered By: Snitz Forums 2000