Subtract hours from two columns datetime sql server

2

I'm doing a query in sqlserver 2000, I have two datetime columns (start, end). I need to subtract the two columns to know how many minutes passed between the start and the end, something like:

select end-start as time_wait from myTable

help please

    
asked by MIKE.- 09.06.2016 в 17:23
source

2 answers

3

More clear, it would be something like this:

SELECT
    Inicio,
    Fin,
    DATEDIFF(minute, Inicio, Fin) as [MinutosTranscurridos]
FROM TuTabla
    
answered by 09.06.2016 в 17:30
2

For this you must use the function DATEDIFF :

SELECT DATEDIFF(MINUTE,Inicio,Fin)
FROM dbo.TuTabla;
    
answered by 09.06.2016 в 17:27