pingcap / pingcap/tidb

After timestampadd() function processing, the `date +00:00:00` cannot be correctly judged

Open
#56,870 6 comments 0 reactions 0 assignees View on GitHub
affects-7.5 affects-8.5 fuzz/comp impact/wrong-result severity/major sig/execution 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)

```
create table lrr_test(`COL1` date);
insert into lrr_test values('2021-01-01');
select col1,timestampadd(month, 1, col1) from lrr_test where timestampadd(month, 1, col1)>='2021-02-01 00:00:00';
```

### 2. What did you expect to see? (Required)
Mysql:
+------------+------------------------------+
| col1 | timestampadd(month, 1, col1) |
+------------+------------------------------+
| 2021-01-01 | 2021-02-01 |
+------------+------------------------------+

### 3. What did you see instead (Required)
TiDB: Empty set

If you change sql into the following sql, you can get correct result. It seems like '2021-02-01 00:00:00' and '2021-02-01' is not equal.
`select col1,timestampadd(month, 1, col1) from lrr_test where timestampadd(month, 1, col1)>='2021-02-01';
`
If you dont use `timestampadd`, you also can get correct result:
`select * from lrr_test where col1>='2021-01-01 00:00:00';`

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

Release Version: v8.4.0
Edition: Community
Git Commit Hash: 2511e928966110964414e6bbb630a565a9870a52
Git Branch: HEAD
UTC Build Time: 2024-10-27 16:16:04
GoVersion: go1.23.2
Race Enabled: false
Check Table Before Drop: false
Store: tikv

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.