Quantcast
Channel: SQL Server Reporting Services, Power View forum
Viewing all articles
Browse latest Browse all 20764

Calculating Days increment to One

$
0
0

 days has been added by 1 if i enter 1year 3months 1day...the result given was 1 year 3months 2day it always increment to 1 no matter days i entered.but if i enter  only days gives me the right output or year and days but months and days too display wrong output

1)

enter

1 year 2days

output

= 1 year 2 days

2) 1 year 3months 1 day

    output

  =  1 year 3months 2day

3)  3months 4 days

     output

   3months 5 days

4)

    5 days

  output

  5 days

this is my result as i run my code...it display the right result as years and months but my days display the wrong output expect if i enter only days..

Public Function RaceDate(length  As Integer ) As String
             dim year As string=0
             dim month As string=0
            dim day As string=0
             dim ReturnString As string

ReturnString=""

If length = 0 then
Return String.Empty
end if



if length >=365
year=cstr((Math.Floor (length / 365)))
length  =(length  Mod 365)

end if

If length >=30 AndAlso length<365 Then
month =(cstr((Math.Floor(length/30))))
length  =(length  Mod 30)

end if

if length<=30 Then
day =cstr((length))

end if

if cint(year)>0

ReturnString= year+"  Years  "

end if

if cint(month)>0

ReturnString= ReturnString +month+" Months "

end if


if cint(day)>0

ReturnString=ReturnString+day+"  Days "
end if

return(ReturnString)

end Function

thanks in advance

 


Viewing all articles
Browse latest Browse all 20764

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>