How do I get the "minutes" difference between 2 times in T SQL? I tried DATEDIFF, but it obviously wants dates. This would be the difference in minutes between 2 times in a day. Any suggestions?
See Question&Answers more detail:osHow do I get the "minutes" difference between 2 times in T SQL? I tried DATEDIFF, but it obviously wants dates. This would be the difference in minutes between 2 times in a day. Any suggestions?
See Question&Answers more detail:osDateDiff
not only work with Date
datatype it even accepts TIME
datatype.
Even if your datatype
is nvarchar
it will work but it should be a valid time
.
Simple Demo
create table time_test(a nvarchar(50),b nvarchar(50))
insert time_test values ('4:00 PM','4:30 PM')
select datediff(minute,a,b) from time_test --30