need a help on get the roundoff value..
where i am passing parameters is coming like month or day or week or year..
i need to convert those values onto days and caluculate the range then i have to roundoff the values as per the requirement
right now i have inserted the list of days , weeks , months and years in the database table.(but this is not the correct way to do this , for an emergecy i have inserted those values getting the roundoff values..)
created funtion:
CREATE FUNCTION [dbo].[fn_conv_Get_DurationAndUnit]
(
@Duration INT
,@DurationUnit VARCHAR(100)
)
RETURNS VARCHAR(250)
AS BEGIN
DECLARE @ReturnDurationUnit VARCHAR(250)
SET @ReturnDurationUnit = (CONVERT(VARCHAR(10),@Duration) + ' ' + LTRIM(RTRIM(@DurationUnit)))
RETURN @ReturnDurationUnit
END
in db insert values like
input value destination value
1 Weeks 1
10 Days 2
11 Days 2
12 Days 2
13 Days 2
14 Days 2
2 Weeks 2
" " "
"
15 Days 3
16 Days 3
17 Days 3
18 Days 3
19 Days 3
3 Weeks 3
20 Days 4
1 Month 4
60 Days 12
480 Days 96
96 Weeks 96
24 Months 96
i need this as more dynamic...please let me know if you have any Questions.