1
I have the following function that calculates the hours 01:00
, returns 60 minutes.
but the column of sql
store in time(0 format) 01:00:00
,
What error in my function, I do not know how to increment the code to calculate the seconds, and return me 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
Thanks for the answer, I program in sql and c# to 2 years, only for own use, and it has function I see and I can’t imagine what it’s for, but that’s exactly what I need. This will be a program like the old and good control of the Windows parents, which today became a Bos.... I want to block my children on certain days and times, but only the programs I think they should not get too involved.
– Rudinei Rufino dos Santos