How can I get the total minute for sql datetime?
Let\'s say:
select getdate() from table
In this way, I will get everything, but I
This query will return the number of minutes past midnight.
declare @now datetime = getdate()
declare @midnight datetime = CAST( FLOOR( CAST( @now AS FLOAT ) ) AS DATETIME )
select datediff(mi, @midnight,@now)
The code
CAST( FLOOR( CAST( "yourDateTimeHere" AS FLOAT ) ) AS DATETIME )
converts any datetime to midnight. Use the datediff with the "mi" function to get the number of minutes past midnight.
Use books online for more date and time math