0 votes
1 view
in SQL by (53.7k points)

Can anyone tell me how to calculate time difference in hours and minutes in SQL Server?

1 Answer

0 votes
by (116k points)
edited ago by

We can be use CONVERT () function to calculate the time difference between two timestamps in hours and minutes.

Here is the example

Declare @Date_2 DATETIME = '2020-04-30 10:01:10.022'

Declare @Date_1 DATETIME = '2020-04-30 10:00:00.000'

Select CONVERT (TIME, @Date_2 - @Date_1) as Elapsed_Time

The output for the above query would be:

To become an SQL expert, you can register for for the best SQL courses by Intellipaat that offers instructor-led training, certification, and job assistance

Related questions

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...