How to get time difference in SQL, if the Date is same?
Here is the way, we can achieve,
DECLARE @date as datetime
DECLARE @date1 as datetime
SET @date = '2009-05-02 22:58:39.037'
SET @date1 = '2009-05-02 23:59:56.087'
The below query will give difference in mili second as i have used ms
SELECT ROUND(cast((datediff(ms, @date, @date1) / 60.0) as FLOAT),2) AS DiffMiliSecond
The below query will give difference in second as i have used ss
SELECT ROUND(cast((datediff(ss, @date, @date1) / 60.0) as FLOAT),2) AS DiffSecond
The below query will give difference in minute as i have used mi SELECT ROUND(cast((datediff(mi, @date, @date1) / 60.0) as FLOAT),2) AS DiffMinute
Saturday, May 2, 2009
Subscribe to:
Post Comments (Atom)
1 comment:
Good very good
Post a Comment