Dear The Code Project,
I am trying to write a simple code function for my reporting services, which is basically converting number to date. please see below for the code:
However i have also some empty rows in my table, so when i runt the report with the following code i get some rows have Error ([rsRuntimeErrorInExpression] The Value expression for the field ‘aaa’ contains an error: Index and length must refer to a location within the string.
Parameter name: length), how can i fix my code?
Can anyone help me?
VT
Public Function ConvertDate(ByVal value As String) As Date
' Converts a date in YYYYMMDD format to DD/MM/YYYY format.
Dim theYear As String = value.SubString(0, 4)
Dim theMonth As String = value.SubString(4, 2)
Dim theDay As String = value.SubString(6, 2)
Dim result As String = theDay & "/" & theMonth & "/" & theYear
return CDate(result)
End Function