swetha batthula
New member
- Joined
- May 23, 2011
- Messages
- 1
- Programming Experience
- Beginner
Hi All,
Im new to VBscripting. I am using the below custom code for SSRS reporting. I get the follwing error when running the report:'Conversion from string"March YYYY' to type 'Date is not valid'.
How to convert a string into date format? I need to complete this report before this evening, any help on this would be greatly appreciated. Value is passed into Month from
Getstartmonth()
Here is the code.
Public Function CheckForMonth(Month as string, minMonth as Date, maxMonth as Date) as string
Dim strMsg as string
Dim convMonth AS datetime
convMonth=FormatDateTime(month,2)
strMsg = ""
If ( convMonth < minMonth ) Then
strMsg = "Date must be higher than " & minMonth.ToString("MM yyyy")
Else If (convMonth > maxMonth) Then
strMsg = "Date must be lesser than " & maxMonth.ToString("MM yyyy")
End If
If strMsg <> ""
Err.Raise(1, "Invalid Parameter", strMsg)
End If
Return "[Time].[Month].&[" & Month.ToString("MMyyyy") & "]"
End Function
Public Function GetStartMonth(maxMonth as Date, minMonth as Date) as String
Dim dtstartMonth as Date
dtstartMonth = DateAdd("M", -1, maxMonth)
If minMonth = maxMonth Then
Return minMonth. ToString("MMMM" & " "&"YYYY")
Else If dtstartmonth >= minMonth Then
Return minMonth. ToString("MMMM" & " "&"YYYY")
End If
Return dtstartMonth. ToString("MMMM" & " "&"YYYY")
End Function
Im new to VBscripting. I am using the below custom code for SSRS reporting. I get the follwing error when running the report:'Conversion from string"March YYYY' to type 'Date is not valid'.
How to convert a string into date format? I need to complete this report before this evening, any help on this would be greatly appreciated. Value is passed into Month from
Getstartmonth()
Here is the code.
Public Function CheckForMonth(Month as string, minMonth as Date, maxMonth as Date) as string
Dim strMsg as string
Dim convMonth AS datetime
convMonth=FormatDateTime(month,2)
strMsg = ""
If ( convMonth < minMonth ) Then
strMsg = "Date must be higher than " & minMonth.ToString("MM yyyy")
Else If (convMonth > maxMonth) Then
strMsg = "Date must be lesser than " & maxMonth.ToString("MM yyyy")
End If
If strMsg <> ""
Err.Raise(1, "Invalid Parameter", strMsg)
End If
Return "[Time].[Month].&[" & Month.ToString("MMyyyy") & "]"
End Function
Public Function GetStartMonth(maxMonth as Date, minMonth as Date) as String
Dim dtstartMonth as Date
dtstartMonth = DateAdd("M", -1, maxMonth)
If minMonth = maxMonth Then
Return minMonth. ToString("MMMM" & " "&"YYYY")
Else If dtstartmonth >= minMonth Then
Return minMonth. ToString("MMMM" & " "&"YYYY")
End If
Return dtstartMonth. ToString("MMMM" & " "&"YYYY")
End Function
Last edited: