isdate 和新西兰返回 false

isdate and new zealand returning false(isdate 和新西兰返回 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

SQL query to group by day(按天分组的 SQL 查询)
What does SQL clause quot;GROUP BY 1quot; mean?(SQL 子句“GROUP BY 1是什么意思?意思是?)
Include missing months in Group By query(在 Group By 查询中包含缺失的月份)
sql group by versus distinct(sql group by 与不同)
How to return a incremental group number per group in SQL(如何在SQL中返回每个组的增量组号)
Count number of records returned by group by(统计分组返回的记录数)