Get the current date and time

Home Page › Forums › BizTalk 2004 – BizTalk 2010 › Get the current date and time

Viewing 1 reply thread
  • Author
    Posts
    • #22421

      How to get the Current date and time in XSLT

    • #22424

      The Xslt1.0 standard used by Biztalk has a limited set of functions and current date time is not one of them.

      You will need to implement some script to do this:

      <xsl:stylesheet xmlns:xsl=”http://www.w3.org/1999/XSL/Transform“ xmlns:msxsl=”urn:schemas-microsoft-com:xslt“ xmlns:var=”http://schemas.microsoft.com/BizTalk/2003/var“ exclude-result-prefixes=”msxsl var userCSharp“ version=”1.0“ xmlns:userCSharp=http://schemas.microsoft.com/BizTalk/2003/userCSharp>
      <xsl:template match=”/“>
        <xsl:element name=”currentDateTime“>
          <xsl:value-of  select=”userCSharp:DateCurrentDateTime()“ />

        <xsl:element>
      </xsl:template>
      <msxsl:script language=”C#“ implements-prefix=”userCSharp“>
      public string DateCurrentDateTime()
      {
      DateTime dt = DateTime.Now;
      string curdate = dt.ToString(“yyyy-MM-dd”, System.Globalization.CultureInfo.InvariantCulture);
      string curtime = dt.ToString(“T”, System.Globalization.CultureInfo.InvariantCulture);
      string retval = curdate + “T” + curtime;
      return retval;
      }
      </msxsl:script>
      </xsl:stylesheet>

Viewing 1 reply thread
  • The forum ‘BizTalk 2004 – BizTalk 2010’ is closed to new topics and replies.