# 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 place the input orderId element on the corresponding output.

   ![Input and output structures.](https://help.qlik.com/talend/en-US/data-mapper-functions-reference-guide/Resources/images/convert_datetime_to_string_01_map.png)
4. Click the output orderDate element and place 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. Place the input orderDate element on the Value argument and save the map.
   ### Example

   ![Input element for Value argument.](https://help.qlik.com/talend/en-US/data-mapper-functions-reference-guide/Resources/images/convert_datetime_to_string_02_expression.png)

## 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>
```