Hi!
I hope someone can help me in that case.
I am migrating as much as possible from Access front end to SQL-Server. Same with functions.
I am not able to convert this function into a scalar function on SQLS 2008:
Function fncRoundToHourParts(dteWorkingtime As Date, x As Integer)
'rounds to parts of hours:x=4 to 15 minutes, x=6 to 10 min., x=12 to 5 min.
fncRoundToHourPartsArbeitszeit = Format(Round(dteWorkingtime * 24 / (1 / x), 0) * (1 / x) / 24, "dd.mm.yyyy hh:nn")
End Function
example:
fncRoundToHourParts(#2014-02-12 10:18:15#,4)
12.02.2014 10:15
I tried:
create FUNCTION dbo.RoundToHourParts
(@dteWorkingtime nvarchar(23), @x int)
RETURNS datetime
AS
BEGIN
-- Declare the return variable here
DECLARE @ResultVar datetime;
-- Add the T-SQL statements to compute the return value here
SELECT @ResultVar=Round(CAST(CONVERT(datetime,@dteWorkingtime ) as float) * 24 / (1 / 4), 0) * (1 / 4) / 24
-- Return the result of the function
RETURN @ResultVar
END
GO
and many other things, I cannot solve it.
Hope someone can help me!
Thanks
Michael
I hope someone can help me in that case.
I am migrating as much as possible from Access front end to SQL-Server. Same with functions.
I am not able to convert this function into a scalar function on SQLS 2008:
Function fncRoundToHourParts(dteWorkingtime As Date, x As Integer)
'rounds to parts of hours:x=4 to 15 minutes, x=6 to 10 min., x=12 to 5 min.
fncRoundToHourPartsArbeitszeit = Format(Round(dteWorkingtime * 24 / (1 / x), 0) * (1 / x) / 24, "dd.mm.yyyy hh:nn")
End Function
example:
fncRoundToHourParts(#2014-02-12 10:18:15#,4)
12.02.2014 10:15
I tried:
create FUNCTION dbo.RoundToHourParts
(@dteWorkingtime nvarchar(23), @x int)
RETURNS datetime
AS
BEGIN
-- Declare the return variable here
DECLARE @ResultVar datetime;
-- Add the T-SQL statements to compute the return value here
SELECT @ResultVar=Round(CAST(CONVERT(datetime,@dteWorkingtime ) as float) * 24 / (1 / 4), 0) * (1 / 4) / 24
-- Return the result of the function
RETURN @ResultVar
END
GO
and many other things, I cannot solve it.
Hope someone can help me!
Thanks
Michael