> For the complete documentation index, see [llms.txt](https://mariadb.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mariadb.com/docs/server/reference/sql-functions/date-time-functions/trunc.md).

# TRUNC

{% hint style="info" %}
Introduced in [MariaDB 12.2](/docs/release-notes/community-server/old-releases/12.2/mariadb-12.2-changes-and-improvements.md).
{% endhint %}

## Syntax

```bnf
TRUNC(date[,fmt])
```

## Description

Returns a [DATETIME](/docs/server/reference/data-types/date-and-time-data-types/datetime.md) truncated according to `fmt`.

**Supported formats:**

Truncate to day: `DD`, `DDD`, `J`\
Truncate to month: `MM`, `MON`, `MONTH`, `RM`\
Truncate to year: `SYEAR`, `SYYYY`, `Y`,`YEAR`, `YY`, `YYY`, `YYYY`

## Examples

```sql
SELECT TRUNC('2025-09-24 12:43','DD');
+--------------------------------+
| TRUNC('2025-09-24 12:43','DD') |
+--------------------------------+
| 2025-09-24 00:00:00            |
+--------------------------------+

SELECT TRUNC('2025-09-24 12:43','MM');
+--------------------------------+
| TRUNC('2025-09-24 12:43','MM') |
+--------------------------------+
| 2025-09-01 00:00:00            |
+--------------------------------+

SELECT TRUNC('2025-09-24 12:43','YY');
+--------------------------------+
| TRUNC('2025-09-24 12:43','YY') |
+--------------------------------+
| 2025-01-01 00:00:00            |
+--------------------------------+
```

<sub>*This page is licensed: CC BY-SA / Gnu FDL*</sub>
