【发布时间】:2021-07-28 00:19:51
【问题描述】:
select
pid, last_name, first_name,
cast(CONVERT(varchar, birth_date, 23) as datetime) as DOB
from
TABLE
where
(last_name = 'Doe' and birth_date = '1999-09-09' and pid = '1234567') or
(last_name = 'Doet' and birth_date = '1999-09-19' and pid = '12345678')
我有很多姓氏要提取。这只是展示了两个例子。由于列表太长,我收到错误消息:
将 varchar 数据类型转换为 datetime 数据类型导致值超出范围。
当我只查询不到500条时,完全没有错误。
【问题讨论】:
-
您使用的是哪个 dbms? (产品特定查询。)
-
请提供样本数据和所需结果,以及适当的数据库标签。
标签: sql date format where-clause