Skip to content

Commit

Permalink
New date macro (#5472)
Browse files Browse the repository at this point in the history
  • Loading branch information
nghi-ly authored May 9, 2024
2 parents 42a26c2 + 95cde1c commit 91d694a
Showing 1 changed file with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ Please make sure to take a look at the [SQL expressions section](#sql-expression
- [cast\_bool\_to\_text](#cast_bool_to_text)
- [safe\_cast](#safe_cast)
- [Date and time functions](#date-and-time-functions)
- [date](#date)
- [dateadd](#dateadd)
- [datediff](#datediff)
- [date\_trunc](#date_trunc)
Expand Down Expand Up @@ -106,6 +107,7 @@ Please make sure to take a look at the [SQL expressions section](#sql-expression
- [cast\_bool\_to\_text](#cast_bool_to_text)
- [safe\_cast](#safe_cast)
- [Date and time functions](#date-and-time-functions)
- [date](#date)
- [dateadd](#dateadd)
- [datediff](#datediff)
- [date\_trunc](#date_trunc)
Expand Down Expand Up @@ -176,6 +178,7 @@ Please make sure to take a look at the [SQL expressions section](#sql-expression
- [safe_cast](#safe_cast)

[**Date and time functions**](#date-and-time-functions)
- [date](#date)
- [dateadd](#dateadd)
- [datediff](#datediff)
- [date_trunc](#date_trunc)
Expand Down Expand Up @@ -884,6 +887,35 @@ For databases that support it, this macro will return `NULL` when the cast fails

## Date and time functions

### date

**Availability**:
dbt v1.8 or later. For more information, select the version from the documentation navigation menu.

<VersionBlock firstVersion="1.8">

__Args__:

* `year`: an integer
* `month`: an integer
* `day`: an integer

This macro converts the `year`, `month`, and `day` into an SQL `DATE` type.

**Usage**:

```sql
{{ dbt.date(2023, 10, 4) }}
```

**Sample output (PostgreSQL)**:

```sql
to_date('2023-10-04', 'YYYY-MM-DD')
```

</VersionBlock>

### dateadd
__Args__:

Expand Down

0 comments on commit 91d694a

Please sign in to comment.