gpt4 book ai didi

mysql日期转换错误

转载 作者:行者123 更新时间:2023-11-29 03:29:25 25 4
gpt4 key购买 nike

我有以下通过 ODBC 连接在 MySQL 中运行的查询。

Select
PUB.oa_nltrans.company,
PUB.oa_nltrans.costcentre As Code,
PUB.oa_nltrans.docdate,

From
PUB.oa_nltrans

Where
PUB.oa_nltrans.company = 01 And
(PUB.oa_nltrans.costcentre >= '14-01' And
PUB.oa_nltrans.costcentre <= '14-06') And
PUB.oa_nltrans.docdate = '31/08/2015'

我试图将日期限制为 1 天 - 2015 年 8 月 31 日,但我收到无效日期错误。

我得到的错误是:

enter image description here

任何人都可以建议在我的查询中使用 convert 来做到这一点的方法吗?

非常感谢,

最佳答案

额外的 , 也在 select 语句中。

SELECT PUB.oa_nltrans.company, PUB.oa_nltrans.costcentre As Code, PUB.oa_nltrans.docdate
FROM PUB.oa_nltrans
WHERE PUB.oa_nltrans.company = 01
AND PUB.oa_nltrans.costcentre BETWEEN '14-01' AND '14-06'
AND date_format(PUB.oa_nltrans.docdate, '%d/%m/%Y') = '31/08/2015'

更整洁一些,因为当您从中选择唯一的表格时,您不需要指定表格。

SELECT company, costcentre AS Code, docdate
FROM PUB.oa_nltrans
WHERE company = 01
AND costcentre BETWEEN '14-01' AND '14-06'
AND date_format(docdate, '%d/%m/%Y') = '31/08/2015'

关于mysql日期转换错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32377987/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com