Saturday, October 09, 2004

Converting Eurpean/American Dates to ISO-format

We are getting European/American dates in the inbound files. We need to convert them to ISO format dates before sending it over to database. This is how to do it:

1) Drag a script functoid over to the map grid.

2) One input to that "functoid" will be the date field from the input schema and the second input will be a constact value of either "1" ( for European format) and "2" (American format).

2) Create a Public Function in external assembly with two paramaters.

Public Function dateformat( byval strDate as string, Byval flag as integer)
Dim newdate As Date
Dim strReturnDate As String

Select Case flag
Case 1
newdate = Convert.ToDateTime(strDate , New CultureInfo("en-gb"))
strReturnDate = Format(newdate , "yyyy-MM-dd")

Case 2
newdate = Convert.ToDateTime(strDate , New CultureInfo("en-us"))
strReturnDate = Format(newdate , "yyyy-MM-dd")
End Select

Return strReturnDate

End Function

No comments: