TechGeek
TechGeek

Reputation: 508

How to convert "YYYY-MM-DD hh mm ss" to "YYYYMMDDhhmm" using xslt

I have date in xml as "YYYY-MM-DD hh mm ss", need to convert that into "YYYYMMDDhhmm", can anyone help me with xslt date formatters ?

 <xsl:if test="not(normalize-space(dt)) = ''">
  <INVDTE>
  <xsl:value-of select="normalize-space(dt)"/>
  </INVDTE>
  </xsl:if>

XMl:

<dt>2020-01-02-15.49.01.000001</dt>

Expected:

202001021549

Upvotes: 0

Views: 282

Answers (1)

Michael Kay
Michael Kay

Reputation: 163458

Simplest way is translate(., '- ', '') to remove the punctuation, then substring(., 1, 12) to remove the seconds value.

Upvotes: 2

Related Questions