Splitting a DateTime value - 8.0

Talend Data Mapper Functions Reference Guide

Version
8.0
Language
English
Product
Talend Big Data Platform
Talend Data Fabric
Talend Data Management Platform
Talend Data Services Platform
Talend MDM Platform
Talend Real-Time Big Data Platform
Module
Talend Studio
Content
Design and Development > Designing Jobs
Last publication date
2023-10-26

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>