# DATETOTEXT

#### Syntax <a href="#syntax.15" id="syntax.15"></a>

**DATETOTEXT**(*datetime, formatstring*)

* *datetime* - the datetime value to be converted into a text - ***Value type**: datetime*
* *formatstring* - the format string for the conversion of *datetime* - ***Value type**: text*

The conversion by *formatstring* follows these rules (case-sensitive):

1. yyyy - is replaced by the year in 4 digits (e.g. 2024)
2. yy - is replaced by the year in 2 digits (the last two digits of the year, e.g. 24)
3. mm - is replaced by the month in 2 digits (e.g. 01, 02, 12)
4. m - is replaced by the month in 1-2 digits (e.g.1, 2, 12)
5. dd - is replaced by the day in 2 digits (e.g. 01, 02, 27)
6. d - is replaced by the day in 1-2 digits (e.g.1, 2, 27)
7. HH - is replaced by the hour in 2 digits (e.g. 01, 02, 15)
8. H - is replaced by the hour in 1-2 digits (e.g.1, 2, 15)
9. MM - is replaced by the minute in 2 digits (e.g. 01, 02, 45)
10. M - is replaced by the minute in 1-2 digits (e.g. 01, 02, 45)
11. SS - is replaced by the seconds in 2 digits (e.g. 01, 02, 23)
12. S - is replaced by the seconds in 1-2 digits (e.g. 01, 02, 23)

#### Remark

* *datetime* is always in UTC time. If the text is to be converted to local time, *datetime* must be adjusted using the GETTIMEZONEOFFSET function.

#### Example

DATETOTEXT with one value:

<div align="left"><figure><img src="https://1085786630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWv5M2BoEVu0kDIV5EPs4%2Fuploads%2Fgit-blob-7c2698eda9beb7291508cd0bd60a20fca19176a7%2Fgrafik.png?alt=media" alt=""><figcaption></figcaption></figure></div>
