I have the following function that calculates the 01:00
hours, returns 60 minutes.
but the sql
column stores in time (0) 01:00:00
format,
What about the error in my function, I do not know how to increment the code to calculate the seconds, and return the entire 60 minutes.
CREATE FUNCTION [dbo].[FN_CONVHORA] (@Horas varchar(10))
RETURNS int
BEGIN
DECLARE @iMinutos INTEGER
Select @iMinutos =
(Convert(int, SubString(Convert(VarChar(10), @Horas), 1,
CharIndex(':', Convert(VarChar(10), @Horas)) - 1)) * 60) + (Convert(int, SubString(Convert(VarChar(10), @Horas),
CharIndex(':', Convert(VarChar(10), @Horas)) + 1,
Len(Convert(VarChar(10), @Horas)) - CharIndex(':', Convert(VarChar(10), @Horas)))))
RETURN @iMinutos
END
GO