# 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="/files/nidsW2DgH0nPJDiUWZll" alt=""><figcaption></figcaption></figure></div>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.nedyx.com/nedyx/clearlines-functions/date-functions/datetotext.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
