Viewing 2 posts - 1 through 2 (of 2 total)
Try This.
DECLARE @date1 DATETIME,
@date2 DATETIME,
@year INT,
@month INT,
@days INT,
@hours INT,
@min-2 INT,
@sec INT
SELECT @date1 = '2012-10-29 18:34:31.013',
@date2 = '2013-12-29 20:54:41.056'
select...
October 29, 2012 at 8:55 am
Try This.
DECLARE @date1DATETIME,
@date2DATETIME,
@yearINT,
@monthINT,
@daysINT,
@hoursINT,
@min-2INT,
@secINT
SELECT@date1 = '2012-10-29 18:34:31.013',
@date2 = '2013-12-29 20:54:41.056'
select@year=DATEDIFF(yy,@date1, @date2),
@date1=DATEADD(yy,@year,@date1),
@month=DATEDIFF(MM,@date1, @date2),
@date1=DATEADD(MM,@month,@date1),
@days=DATEDIFF(DD,@date1, @date2),
@date1=DATEADD(dd,@days,@date1),
@hours=DATEDIFF(hh,@date1, @date2),
@date1=DATEADD(hh,@hours,@date1),
@min-2=DATEDIFF(MI,@date1, @date2),
@date1=DATEADD(mi,@min,@date1),
@sec=DATEDIFF(SS,@date1, @date2)
SELECTCASE WHEN @year= 0 THEN '' ELSE CAST...
October 29, 2012 at 8:33 am
Viewing 2 posts - 1 through 2 (of 2 total)