isdate and new zealand returning false(isdate 和新西兰返回 false)
问题描述
问题来了:
select ISDATE('2012-06-21 4:11 P.M.')
文化是 en-NZ(新西兰),上面的字符串日期是他们格式化日期的方式.
The culture is en-NZ (New Zealand) and the string date above is how they format their dates.
在这种情况下,我如何使 ISDATE 为真?
How do I make ISDATE true in this case?
推荐答案
理想情况下,您可以更好地控制字符串格式.如果您以标准格式传递,则不应关心文化是 EN-NZ 还是其他文化,例如:
Ideally you would control the string format better than that. You shouldn't care whether the culture is EN-NZ or anything else if you pass in a standard format, such as:
SELECT ISDATE('20120621 16:11'); -- will never fail regardless of locale/language/DMY
如果您需要允许人们以他们希望的任何格式输入日期,那么您必须以各种方式处理它.例如:
If you need to allow people to enter dates in any format they wish, then you have to deal with it in various ways. For example:
SELECT ISDATE(CONVERT(DATETIME, REPLACE('2012-06-21 4:11 P.M.', '.', ''), 120));
这篇关于isdate 和新西兰返回 false的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:isdate 和新西兰返回 false


基础教程推荐
- MySQL 5.7参照时间戳生成日期列 2022-01-01
- while 在触发器内循环以遍历 sql 中表的所有列 2022-01-01
- 如何在 CakePHP 3 中实现 INSERT ON DUPLICATE KEY UPDATE aka upsert? 2021-01-01
- ORA-01830:日期格式图片在转换整个输入字符串之前结束/选择日期查询的总和 2021-01-01
- 带有WHERE子句的LAG()函数 2022-01-01
- 带更新的 sqlite CTE 2022-01-01
- CHECKSUM 和 CHECKSUM_AGG:算法是什么? 2021-01-01
- MySQL根据从其他列分组的值,对两列之间的值进行求和 2022-01-01
- 使用 VBS 和注册表来确定安装了哪个版本和 32 位 2021-01-01
- 从字符串 TSQL 中获取数字 2021-01-01