---
title: "DATE_TRUNC"
description: "La funci\u00F3n SQL DATE_TRUNC devuelve el valor truncado de un datetime."
language: es
source_language: en
translation_state: complete
canonical: https://documentation.invantive.eu/es/docs/invantive-universalsql/grammar/sql-functions/date-trunc
original: https://documentation.invantive.eu/en/docs/invantive-universalsql/grammar/sql-functions/date-trunc
updated: 2026-12-04T13:33:08Z
license: https://documentation.invantive.eu/es/
---

## Sintaxis
```mermaid
%%{init: {
  'theme': 'base',
  'flowchart': { 'padding': '7', 'nodeSpacing': '20', 'rankSpacing': '20' },
  'themeVariables': {
    'fontSize': '11px',
    'fontFamily': 'Arial'
  }
}}%%
flowchart LR
    Start((START)) --> DATE_TRUNC[DATE_TRUNC]:::quoted
    DATE_TRUNC --> End((END))
```

## Propósito
La función SQL `DATE_TRUNC` devuelve el valor truncado de un `datetime`.

Véanse también [[DATE_CEIL]], [[DATE_FLOOR]] y [[DATE_ROUND]].

Parámetros:
- Precision (`varchar2`): one of `millenium`, `century`, `decade`, `year`, `quarter`, `month`, `week`, `day`, `hour`, `minute`, `second`, `milliseconds` and `microseconds`. Una semana comienza el domingo.
- Fecha/hora (`datetime`): la fecha/hora a truncar.

Devuelve: la fecha/hora de entrada truncada con la precisión definida como `datetime`. Se devuelve el valor original cuando se especifica una precisión no listada.

## Ejemplos
El siguiente ejemplo recupera el valor truncado de la hora del sistema por año:
```sql
select date_trunc('year', to_date('19870315', 'YYYYMMDD'))

-------------------
01-01-1987 00:00:00
```
El siguiente ejemplo recupera el valor truncado de una fecha por mes:
```sql
select date_trunc('month', to_date('20990317', 'YYYYMMDD'))

-------------------
01-03-2099 00:00:00
```
El siguiente ejemplo recupera el valor truncado del jueves 1 de octubre 2026 por semana; una semana comienza el domingo:
```sql
select date_trunc('week', to_date('20261001', 'YYYYMMDD'))

-------------------
27-09-2026 00:00:00
```

