Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Altova mapforce string date to DateTime

Tags:

altova

Hopefully someone else out there uses Altova Mapforce for this.

Using XSLT to convert one xml to another, in the source XML they have the dates as M/D/YYYY, i need to convert them to the standard datetime format used by.. well, everything.

So, i'm playing with using the tokenize function of XSLT to split on / to get my parts, now, i want to take part 1 and say it's the day, but not sure how to assign results of the tokenize expression to variables using MapForce.

Anyone else do this? or rather, what's the best way to convert a string date to a datetime?

Thanks for the ideas

EDIT. my input is a string '1/31/2012' and my output needs to be xs:dateTime (or xs:date, assuming that xs:date can be easily converted to dateTime)

I've got a method setup to concatenate strings together and convert them to YYYY-MM-DD format, but it still reports that this is invalid for dateTime (Cast Failed, invalid lexical value 2012-1-31)

Perhaps YYYY-MM-DD is not the valid format for dateTime?

like image 472
Beta033 Avatar asked May 24 '26 22:05

Beta033


1 Answers

Ended up creating a component to do this. my particular problem was that '2012-1-31' cannot be formatted to a date or dateTime, however 2012-01-31 can. so this became as simple as formatting the number and padding with characters before trying to cast as a date.

like image 113
Beta033 Avatar answered May 27 '26 22:05

Beta033