本文介紹了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的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!