Display or Format days, Month and years in ssrs 2008
hi,
i have my reports running in my ssrs 2008. but the problem is that i cant display properly if a user select more than 2 or three but to select only 1 it display correctly.eg. when i select 3years plus 11 days, output display is 3.11 years which does
not have a meaning..all i want is that 3 years 11 days.and this should be the same if i select months too eg 3 years 2 months 11 days..
my code is something like this..
Public Function NaturalLength(length As Integer) As String
' days 0 - 60
' months 61 - 730
' years 731 plus
If length = 0 then
Return String.Empty
ElseIf length < 61 Then
Return String.Format("{0} days", length)
ElseIf length > 60 AndAlso length < 731 Then
Return String.Format("{0:0.0} months", length / 30.4375)
Else
Return String.Format("{0:0.0} years", length / 365.25)
End If
End Function
in my expression i had
Code.NaturalLength(Avg(Fields!Length.Value))..to take out the average of a entered field
i need help, if anyone can figure it where i get wrong.thanks for being patient...
Thanks in advance
A.Vadz
October 16th, 2012 8:33pm
Hi There
Thanks for your posting. Please try this function that might resolve your problem
Public Function NaturalLength(length As integer) As String
' days 0 - 60
' months 61 - 730
' years 731 plus
dim length1 As string=0
dim length2 As string=0
dim length3 As string=0
If length = 0 then
Return String.Empty
end if
if length >= 731
length1=cstr(Math.Floor (length / 365.25))
length
=(length Mod 365.25)
end if
If length > 60 AndAlso length < 731 Then
length2 =cstr((Math.Floor(length / 30.4375 )) )
length
=length Mod 30.4375
end if
if length < 61 Then
length3 =cstr(length)
End If
Return (length1+" Years " +length2+ "
Months " +length3 + " days")
End Function
Public Function NaturalLength(length As integer) As String
' days 0 - 60
' months 61 - 730
' years 731 plus
dim length1 As string=0
dim length2 As string=0
dim length3 As string=0
If length = 0 then
Return String.Empty
end if
if length >= 731
length1=cstr(Math.Floor (length / 365.25))
length =(length Mod 365.25)
end if
If length > 60 AndAlso length < 731 Then
length2 =cstr((Math.Floor(length / 30.4375 )) )
length =length Mod 30.4375
end if
if length < 61 Then
length3 =cstr(length)
End If
Return (length1+" Years " +length2+ " Months " +length3 + " days")
End Function
I am putting some screenshot for your help
I hope this will help. If you have any questions please do ask
Many Thanks
Syed Qazafi Anjum
Please click "Mark as Answer" if this resolves your problem or "Vote as Helpful" if you find it helpful
Free Windows Admin Tool Kit Click here and download it now
October 16th, 2012 10:07pm
Hi Syed Qazafi Anjum,
Thanks a Million..:)...thanks u sooo much...:)
it works fine
A.Vadz
October 16th, 2012 11:04pm
i have some minor issues all about the range
eg. days 0-30day
month -1-1year
years may 1-life
i know that may have a conflict but if the code is correct it may fine..so what is the possible range in days months and years that can meet the code you write
A.Vadz
Free Windows Admin Tool Kit Click here and download it now
October 17th, 2012 12:20am