Pages

Tuesday, March 1, 2011

A function for Convert System date to Sepcified format date:

Public Function dateManipulate(sDate)

If Len(sDate) > 10 Then
Reporter.ReportEvent micWarning, "Error! Bad Input", "Bad Input. Actual: " & sDate & ". Expected: m-d/yyyy"
End If

locDelimOne = InStr(1, sDate, "-")
locDelimTwo = InStr(1, sDate, "/")

If locDelimOne = 2 Then
sMonth = Left(sDate, 1)
sMonth = "0" & sMonth
ElseIf locDelimOne = 3 Then
sMonth = Left(sDate, 2)
Else
Reporter.ReportEvent micWarning, "Error! Bad Input", "Bad Input. Actual: " & sDate & ". Expected: m-d/yyyy"
End If

sDay = Mid(sDate, locDelimOne + 1, locDelimTwo - locDelimOne - 1)

If Len(sDay) = 1 Then
sDay = "0" & sDay
End If

sLen = Len(sDate) - locDelimTwo
sYear = Mid(sDate, locDelimTwo + 3, sLen)

iDate = sMonth & "/" & sDay & "/" & sYear

dateManipulate = iDate

End Function

No comments:

Post a Comment