Skip to main content Skip to complementary content

Splitting a DateTime value

Use an ExtractFromDateTime function to split a DateTime value into separate date and time values.

About this task

You have created an input and an output structure. You can use the samples provided below.
In this example, you have an input XML file containing a datetime element. You want to split its value to get a date element and a time element. You can use the following XML sample as input:
<root>
	<datetime>2020-11-20T09:28:50</datetime>
</root>
You can use the following XML sample to create your output structure:
<root>
	<date/>
	<time/>
</root>

Procedure

  1. Open your input structure and click the datetime 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. Open your output structure and change the data types of the date and time elements to Date and Time, respectively.
  4. Create a map with your input and output structures.
  5. Drag and drop an ExtractFromDateTime function on the output date element.
    The value to extract is set to Date by default.
  6. Drag and drop the input datetime element on the Value argument.
  7. Drag and drop an ExtractFromDateTime function on the output time element.
  8. Double-click the function and select Time in the Extract What? drop-down list, then click OK.
  9. Drag and drop the input datetime element on the Value argument.

Results

Your map in now configured. You can use the Test Run feature to see the result. In this example, the following output is returned:
<root>
  <date>2020-11-20</date>
  <time>09:28:50.000+01:00</time>
</root>

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!