Formatting dates using XPath

I have the following xpath expressions...

//ns:response[1]/ns:return[1]/legs[1]/startDate[1] (Value 01/01/2011) //ns:response[1]/ns:return[1]/legs[1]/startTime[1] (Value 12:13)

I need to format and concat these values into something like this


Is this possible to do using xpath functions? An example would be appreciated.

The date format in the input data is dd/mm/yyyy.


As by @Michael Key suggestion (+1), three substring() and one concat() is all what you need. Check at this XSLT example using the XPath you are searching for (use of variables to make expression readable):

<xsl:template match="/"> <xsl:variable name="sD" select="'01/01/2011'"/> <xsl:variable name="sT" select="'12:13'"/> <xsl:value-of select="concat( substring($sD,7),'-', substring($sD,4,2),'-', substring($sD,1,2),'T', $sT,':00')"/> </xsl:template>


It would help to know whether your 01/01/2011 is d/m/y or m/d/y. Either way, it's just a question of calling substring() three times to extract the parts of the data, and then concat() to build up the result.


Look at XPath 1.0 functions: concat, substring, substring-before, substring-after.


  • MomentJS - convert datetime from UTC to different timezone
  • How to hit post request with NSDictionary as parameter
  • Stuck on parsing a JSON response to a Java Object in Android
  • json array for events array in jQuery fullcalendar
  • sort array value in alphabetical order [duplicate]
  • counting islands in R csv
  • MongoDB shell script using projection to format date and get local time
  • how to handle large size of update query in mysql with laravel
  • How to show a specific VC , more like navigate to a stack of VC
  • A simple datepicker in VueJS
  • How to make Plotly chart with year mapped to line color and months on x-axis
  • How to parsing NSDate to RFC 822 always use in English?
  • iOS Date formatting
  • Adding independent aspx/asmx pages into DotNetNuke
  • how do i write assembly code from c#?
  • Custom Tabgroup Appcelerator
  • Why value captured by reference in lambda is broken? [duplicate]
  • PHPUnit_Framework_TestCase class is not available. Fix… - Makegood , Eclipse
  • Java Scanner input dilemma. Automatically inputs without allowing user to type
  • Projection media query: browser support and workarounds?
  • Illegal mix of collations for operation for date/time comparison
  • Different response to non-authenticated users and AJAX calls
  • output of program is not same as passed argument
  • Does CUDA 5 support STL or THRUST inside the device code?
  • Statically linking a C++ library to a C# process using CLI or any other way
  • what is the difference between the asp.net mvc application and asp.net web application
  • Release, debug version and Authorization Google?
  • Why winpcap requires both .lib and .dll to run?
  • Matrix multiplication with MKL
  • using conditional logic : check if record exists; if it does, update it, if not, create it
  • Hits per day in Google Big Query
  • Why joiner is not used after Sequence generator or Update statergy
  • embed rChart in Markdown
  • Recursive/Hierarchical Query Using Postgres
  • Sorting a 2D array using the second column C++
  • How to get NHibernate ISession to cache entity not retrieved by primary key
  • Binding checkboxes to object values in AngularJs
  • How can I use `wmic` in a Windows PE script?
  • UserPrincipal.Current returns apppool on IIS
  • Unable to use reactive element in my shiny app