Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have a problem that i need to solve
,its about overtime calculation,
the calculation of first hour is different with the second hour,

example : an employee have an overtime calculation about 7 hour,

so the calculation is :
1 *1.5 =1.5
and 6 *2 =12
so he have about 13.5 overtime salary.

What I have tried:

how can i solve this?
i wish someone call help me
Posted
Updated 11-May-22 19:09pm

1 solution

Something like this:
SQL
CREATE FUNCTION GetOvertimeHours 
(
@OverHours FLOAT
)
RETURNS FLOAT
AS
BEGIN
	DECLARE @Hours FLOAT
    IF (@OverHours <= 0.0) RETURN 0.0
    IF (@OverHours <= 1.0) RETURN @OverHours * 1.5
    SET @OverHours = @OverHours - 1.0
    SET @Hours = 1.5 + @OverHours * 2.0
    RETURN @Hours
END
GO
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900