Skip to main content Skip to complementary content

Converting a DateTime element to a string

Use the FormatDateTime function to convert an element with a DateTime data type to a string with a different date format.

Before you begin

You have created an input and an output structure. You can use the sample provided below.

About this task

In this example, you have an XML file in which input date element contains the value 2020-08-21T12:39:20.970Z. The output should be converted to 20200821.
You can use the following sample to create your input and output structures:
<order>
	<orderDate>2020-08-21T12:39:20.970Z</orderDate>
	<orderId>168484984</orderId>
</order>

Procedure

  1. Open your input structure and click the orderDate element, then click Read Only and select Editable in the drop-down list.
  2. In the Data Type drop-down list, select Date/Time.
  3. Create a map with your input and output structures and drag and drop the input orderId element on the corresponding output.
  4. Click the output orderDate element and drag a FormatDateTime function in the Value tab.
  5. Double-click the function to open its properties and enter the new date pattern in the Pattern field.

    Example

    yyyyMMdd
  6. Click OK.
  7. Drag the input orderDate element on the Value argument and save the map.

    Example

Results

The map is now configured to format the input DateTime element. If you click Test Run, the following data is returned:
<order>
  <orderDate>20200821</orderDate>
  <orderId>168484984</orderId>
</order>

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – please let us know!