prabu R
prabu R

Reputation: 2209

numeric to minutes in sql

I need to convert the numeric value into minute value in SQL Server.

For example, let us consider the input variable @ScheduleTime of type numeric(38,2) and the output variable @NumberOfMinutes of type int.

Given @ScheduleTime = 2.35 (which means 2 hours 35 minutes), I need the output to be @NumberOfMinutes = 155

Upvotes: 0

Views: 89

Answers (1)

chrisb
chrisb

Reputation: 2210

declare @ScheduleTime numeric(38,2)
set @ScheduleTime = 2.35

declare @NumberOfMinutes int
set @NumberOfMinutes = FLOOR(@ScheduleTime) * 60 + (@ScheduleTime % 1) * 100

print @NumberOfMinutes

Upvotes: 3

Related Questions