Hi pandeygolu420,
Please refer below SQL Query.
SQL
CREATE TABLE ##Time
(
TimeId INT IDENTITY(1,1)
,StartTime VARCHAR(50)
,EndTime VARCHAR(50)
)
INSERT INTO ##Time VALUES('10:00 AM','10:30 AM')
INSERT INTO ##Time VALUES('10:30 AM','11:00 AM')
INSERT INTO ##Time VALUES('11:00 AM','11:30 AM')
INSERT INTO ##Time VALUES('11:30 AM','12:00 PM')
INSERT INTO ##Time VALUES('12:00 PM','12:30 PM')
SELECT a.TimeId
,a.StartTime 'StartTime'
,a.EndTime 'EndTime'
,DATEDIFF(mi,(CONVERT(DATETIME,a.StartTime)),(CONVERT(DATETIME,a.EndTime))) AS 'TimeDifference'
FROM ##Time a
SELECT * FROM ##Time
DROP TABLE ##Time
Output
TimeId |
StartTime |
EndTime |
TimeDifference |
1 |
10:00 AM |
10:30 AM |
30 |
2 |
10:30 AM |
11:00 AM |
30 |
3 |
11:00 AM |
11:30 AM |
30 |
4 |
11:30 AM |
12:00 PM |
30 |
5 |
12:00 PM |
12:30 PM |
30 |