SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Difference between dates displayed in days, hours, minutes and seconds

By Robinson Pingus,

-- Mostrar una diferencia de solo fechas
SELECT dbo.ufn_DifferenceBetweenDateTimes('2017-10-03 00:00:00', '2017-10-12 00:00:00')
-- Return: 9d 00:00:00
-- Mostrar una diferencia en minutos
SELECT dbo.ufn_DifferenceBetweenDateTimes('2017-10-05 07:30:00', '2017-10-05 07:55:00')
-- Return: 0d 00:25:00
-- Mostrar una diferencia en la misma fecha
SELECT dbo.ufn_DifferenceBetweenDateTimes('2017-09-01 01:46:00', '2017-09-01 10:55:00')
-- Return: 0d 09:09:00
-- Mostrar una diferencia de dias
SELECT dbo.ufn_DifferenceBetweenDateTimes('2017-11-21 08:21:00', '2017-12-06 18:00:00')
-- Return: 15d 09:39:00

Total article views: 377 | Views in the last 30 days: 6
 
Related Articles
FORUM

faster dbo.ufn_vbintohexstr - varbinary to hex

Comments posted to this topic are about the item [B]faster dbo.ufn_vbintohexstr - varbinary to hex[/...

FORUM

Procedure return value problem

Procedure return value problem

FORUM

decryptbycert returns null

decryptbycert returns null

FORUM

Help Needed - Function Returning Table

Function Returning Table

FORUM

RETURN clause, clarification

Does RETURN abort, or does it return a value?

 
Contribute