pingcap / pingcap/tidb

UTC_TIMESTAMP() rounds fraction part instead of truncating it

Open
#56,430 4 comments 0 reactions 0 assignees View on GitHub
severity/minor sig/sql-infra type/bug
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Bug Report

Please answer these questions before submitting your issue. Thanks!

### 1. Minimal reproduce step (Required)

```
tidb> select utc_timestamp(6), utc_timestamp(), now(), now(6);
+----------------------------+---------------------+---------------------+----------------------------+
| utc_timestamp(6) | utc_timestamp() | now() | now(6) |
+----------------------------+---------------------+---------------------+----------------------------+
| 2024-10-01 08:31:57.868668 | 2024-10-01 08:31:58 | 2024-10-01 10:31:57 | 2024-10-01 10:31:57.868667 |
+----------------------------+---------------------+---------------------+----------------------------+
1 row in set (0.00 sec)
```

### 2. What did you expect to see? (Required)
`UTC_TIMESTAMP()` should never round up, it is very confusing if time is rounding up, since it will be earlier than what the clock on the wall shows.

### 3. What did you see instead (Required)
Truncating (or always rounding down).

### 4. What is your TiDB version? (Required)

```
tidb_version(): Release Version: v8.4.0-alpha-325-g74034d4ac2
Edition: Community
Git Commit Hash: 74034d4ac243b3c14dbf5f8a9edb92e740da4212
Git Branch: now-diff-utc_timestamp
UTC Build Time: 2024-10-01 08:23:56
GoVersion: go1.22.1
Race Enabled: false
Check Table Before Drop: false
Store: unistore
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.