Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: date_format #11774

Merged
merged 2 commits into from
Jun 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions docs/doc/15-sql-functions/30-datetime-functions/dateformat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
title: DATE_FORMAT
---

import FunctionDescription from '@site/src/components/FunctionDescription';

<FunctionDescription description="Introduced: v1.1.39"/>

Converts a date value to a specific string format. To customize the format of date and time in Databend, you can utilize specifiers. These specifiers allow you to define the desired format for date and time values. For a comprehensive list of supported specifiers, see [Formatting Date and Time](../../13-sql-reference/10-data-types/20-data-type-time-date-types.md#formatting-date-and-time).

## Syntax

```sql
DATE_FORMAT(<date>, <format>)
```

## Return Type

String.

## Examples

```sql
SELECT DATE_FORMAT('2022-12-25', 'Month/Day/Year: %m/%d/%Y')

+-------------------------------------------------------+
| date_format('2022-12-25', 'month/day/year: %m/%d/%y') |
+-------------------------------------------------------+
| Month/Day/Year: 12/25/2022 |
+-------------------------------------------------------+
```
2 changes: 1 addition & 1 deletion docs/doc/15-sql-functions/60-conversion-functions/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Databend also offers a variety of functions for converting expressions into diff
| TO_INT32( expr ) | Converts a value to INT32 data type | TO_INT32('123') | 123 |
| TO_INT64( expr ) | Converts a value to INT64 data type | TO_INT64('123') | 123 |
| TO_STRING( expr ) | Converts a value to STRING data type | TO_STRING(10) | 10 |
| TO_STRING( expr, expr ) | Converts a date value to a specific STRING format | TO_STRING('2022-12-25', 'Month/Day/Year: %m/%d/%Y') | Month/Day/Year: 12/25/2022 |
| TO_STRING( expr, expr ) | Alias for [DATE_FORMAT](../30-datetime-functions/dateformat.md) | TO_STRING('2022-12-25', 'Month/Day/Year: %m/%d/%Y') | Month/Day/Year: 12/25/2022 |
| TO_UINT8( expr ) | Converts a value to UINT8 data type | TO_UINT8('123') | 123 |
| TO_UINT16( expr ) | Converts a value to UINT16 data type | TO_UINT16('123') | 123 |
| TO_UINT32( expr ) | Converts a value to UINT32 data type | TO_UINT32('123') | 123 |
Expand Down