Skip to content

Commit 8ab8472

Browse files
authored
docs: to_ timestamp updates (#1000)
* updates * Update 20-data-type-time-date-types.md
1 parent 9329304 commit 8ab8472

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

docs/en/sql-reference/00-sql-reference/10-data-types/20-data-type-time-date-types.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Basic Date and Time data type.
44
---
55
import FunctionDescription from '@site/src/components/FunctionDescription';
66

7-
<FunctionDescription description="Introduced or updated: v1.2.564"/>
7+
<FunctionDescription description="Introduced or updated: v1.2.575"/>
88

99
## Date and Time Data Types
1010

@@ -258,7 +258,7 @@ In Databend, certain date and time functions like [TO_DATE](../../20-sql-functio
258258
| | | DATE & TIME SPECIFIERS: |
259259
| %c | Sun Jul 8 00:34:60 2001 | Locale’s date and time (e.g., Thu Mar 3 23:05:25 2005). |
260260
| %+ | 2001-07-08T00:34:60.026490+09:30 | ISO 8601 / RFC 3339 date & time format. |
261-
| %s | 994518299 | UNIX timestamp, the number of seconds since 1970-01-01 00:00 UTC. |
261+
| %s | 994518299 | UNIX timestamp, the number of seconds since 1970-01-01 00:00 UTC. Databend recommends converting the Integer string into an Integer first, other than using this specifier. See [Converting Integer to Timestamp](/sql/sql-functions/datetime-functions/to-timestamp#example-2-converting-integer-to-timestamp) for an example. |
262262
| | | SPECIAL SPECIFIERS: |
263263
| %t | | Literal tab (\t). |
264264
| %n | | Literal newline (\n). |

docs/en/sql-reference/20-sql-functions/05-datetime-functions/to-timestamp.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: TO_TIMESTAMP
33
---
44
import FunctionDescription from '@site/src/components/FunctionDescription';
55

6-
<FunctionDescription description="Introduced or updated: v1.2.538"/>
6+
<FunctionDescription description="Introduced or updated: v1.2.575"/>
77

88
Converts an expression to a date with time.
99

@@ -135,9 +135,22 @@ SELECT TO_TIMESTAMP(1), TO_TIMESTAMP(-1);
135135
└───────────────────────────────────────────┘
136136
```
137137

138-
:::tip
138+
You can also convert an Integer string into a timestamp:
139139

140-
Please note that a Timestamp value ranges from 1000-01-01 00:00:00.000000 to 9999-12-31 23:59:59.999999. Databend would return an error if you run the following statement:
140+
```sql
141+
SELECT TO_TIMESTAMP(TO_INT64('994518299'));
142+
143+
┌─────────────────────────────────────┐
144+
│ to_timestamp(to_int64('994518299')) │
145+
├─────────────────────────────────────┤
146+
│ 2001-07-07 15:04:59 │
147+
└─────────────────────────────────────┘
148+
```
149+
150+
:::note
151+
- You can use `SELECT TO_TIMESTAMP('994518299', '%s')` for the conversion as well, but it is not recommended. For such conversions, Databend recommends using the method in the example above for better performance.
152+
153+
- A Timestamp value ranges from 1000-01-01 00:00:00.000000 to 9999-12-31 23:59:59.999999. Databend would return an error if you run the following statement:
141154

142155
```bash
143156
root@localhost:8000/default> SELECT TO_TIMESTAMP(9999999999999999999);

0 commit comments

Comments
 (0)