I am trying to write this Excel formula into T-SQL (to write a function).
Expected output is 0.71944444, but currently my output (using T-SQL) is 24.0000.
I am not sure why we have to add a day to same date and subtract the same date.
Bottom is a screenshot from Excel:
This is what I have so far in T-SQL:
CREATE FUNCTION [dbo].[fn_0921] (
@Punch_Start nvarchar(max)
)
RETURNS decimal(36, 8) AS
BEGIN
DECLARE @return_value nvarchar(max);
SET @return_value =
DATEDIFF(
MINUTE, CAST(@Punch_Start AS datetime2),
(
dateadd(
day, 1, CAST(@Punch_Start AS datetime2)
)
)
)
/ (60.0)
RETURN @return_value
END;
Thanks for help.