is there a way to dynamically change the format of a string if the string is DD.MM.YYYY or MM.DD.YYYY to YYYY.MM.DD?
I've tried using a code that checks is the day or month is below 12. If they're below 12 then they're month but if they're above 12 then it is a day.
But I'm what I'm trying to do is to have a flexible code that knows what is date or month because if they're both below 12, then the logic that I came up with above will not work.
is there a way to have a flexible code that doesn't assume the original format of the string?
I've tried using a code that checks if the day or month is below 12. Does anyone have a flexible code that doesn't assume that the original string will have a define position of day or month
EDIT: This is the current code that I have
<xsl:if test=" var-get('QUALIFIER') = '001' and var-get('DATE_STRING') != ''">
<!-- REPLACE ALL - AND . WITH / -->
<xsl:value-of select=" var-put('DATE_STRING', translate( var-get('DATE_STRING'), '-.', '//'))"/>
<!-- CONVERT STRING TO ARRAY WITH / AS DELIMITER -->
<xsl:value-of select=" perform ('FUNCTION_TO_TURN_STRING_TO_ARRAY', var-get('DATE_STRING'), '/')"/>
<xsl:value-of select=" var-put('DATE_STRING_DD', array-get('ReturnARRAYList[0]'))"/>
<xsl:value-of select=" var-put('DATE_STRING_MM', array-get('ReturnARRAYList[1]'))"/>
<xsl:value-of select=" var-put('DATE_STRING_YYYY', array-get('ReturnARRAYList[2]'))"/>
<!-- <xsl:value-of select=" var-put('DATE_STRING_DD', substring( var-get('DATE_STRING_DD'), -->
<!-- strlen-b( var-get('DATE_STRING_DD')) - '1', -->
<!-- strlen-b( var-get('DATE_STRING_DD'))))"/> -->
<xsl:value-of select=" var-put('DATE_STRING_DD', translate( var-get('DATE_STRING_DD'), translate( var-get('DATE_STRING_DD'), '0123456789', ''), ''))"/>
<xsl:if test=" strlen-b( var-get('DATE_STRING_DD')) = '2'">
<xsl:value-of select=" var-put('DATE_STRING_YYYY', substring( var-get('DATE_STRING_YYYY'),1,4))"/>
</xsl:if>
<xsl:if test=" strlen-b( var-get('DATE_STRING_DD')) = '4'">
<xsl:value-of select=" var-put('DATE_STRING_YYYY', substring( var-get('DATE_STRING_YYYY'),1,2))"/>
<xsl:value-of select=" var-put('DATE_STRING_YYYY_TEMP', var-get('DATE_STRING_YYYY'))"/>
<xsl:value-of select=" var-put('DATE_STRING_DD_TEMP', var-get('DATE_STRING_DD'))"/>
<xsl:value-of select=" var-put('DATE_STRING_YYYY', var-get('DATE_STRING_DD_TEMP'))"/>
<xsl:value-of select=" var-put('DATE_STRING_DD', var-get('DATE_STRING_YYYY_TEMP'))"/>
</xsl:if>
the code above determines what the delimiter used for the date then replaces it with a slash. Then converts the string to array with the / as delimiters. Then swaps the DD and YYYY.
I couldn't figure out how to create a code that determines the day if the format is DD.MM.YYYY or MM/DD/YYYY.