Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

T SQL: How get all minutes from Time type

Tags:

tsql

I have the following code and I want get all minutes from time type.

declare @time time
set @time = '01:30'

declare @minutes int

--select @minutes = convert time to minutes here

select @minutes -- @minutes == 90

Please help.

like image 802
Nazar Tereshkovych Avatar asked Oct 02 '12 11:10

Nazar Tereshkovych


People also ask

How can I get minutes in SQL?

MINUTE() : The MySQL MINUTE() function is used for return the minute part of a datetime value. It can be between 0 to 59. When the datetime is passed in MINUTE() function then it will return the minute value .

How get number of minutes from datetime in SQL Server?

In this way, I will get everything, but I only want to get total minute. For eg, if the time is 07:10:35 , I want 430 . How to achieve that? The value from the field is 01-01-2001 07:10:40 The result I want is 430 ((7*60)+10) only.

How do I subtract minutes from a timestamp in SQL?

MySQL SUBTIME() Function The SUBTIME() function subtracts time from a time/datetime expression and then returns the new time/datetime.


1 Answers

The difference between @time & midnight;

set @minutes = datediff(minute, '00:00:00', @time)
like image 190
Alex K. Avatar answered Jan 02 '23 04:01

Alex K.