# [KB]关于 TiDB 的 SQL 中 IN 函数条件为日期时返回结果错误

## Issue

SQL 中 IN 函数的条件为日期时，返回的结果错误。

## Root Cause

内置函数 IN 对时间类型的实现有问题，在进行一些如 date in (...) 的时候，结果可能出错。

Github Issue：[https://github.com/pingcap/tidb/issues/21290](https://github.com/pingcap/tidb/issues/21290)

## Diagnostic Steps

### 复现步骤

```sql
CREATE TABLE `bugtest` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`exp_date` datetime NOT NULL,
`col` varchar(50) NOT NULL DEFAULT '',
PRIMARY KEY (`id`,`exp_date`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=15440002;

INSERT INTO `bugtest` VALUES (15282431,'2020-10-09 00:00:00','3'),(15282361,'2020-10-12 00:00:00','3');

select \* from bugtest;
+----------+---------------------+-----+
| id       | exp_date            | col |
+----------+---------------------+-----+
| 15282431 | 2020-10-09 00:00:00 | 3   |
| 15282361 | 2020-10-12 00:00:00 | 3   |
+----------+---------------------+-----+
```

在事务中更新列 col

```sql
set autocommit=0;
update bugtest set col='4';
```

查看结果

```sql
实际查询结为空：
select \* from bugtest where exp_date in ('2020-10-12','2020-10-1');
Empty set (0.00 sec)

期望查询结果：
select \* from bugtest where exp_date in ('2020-10-12','2020-10-1');
+----------+---------------------+-----+
| id       | exp_date            | col |
+----------+---------------------+-----+
| 15282361 | 2020-10-12 00:00:00 | 4   |
+----------+---------------------+-----+
1 row in set (0.00 sec) 
```

## Resolution

v4.0.9 及以上版本已经修复

PR：[https://github.com/pingcap/tidb/pull/21293](https://github.com/pingcap/tidb/pull/21293)

## Workaround

N/A