Вопрос по sql-server – Функция SQL Server ISDATE () - может кто-нибудь объяснить это?

5

Error: User Rate Limit Exceeded

SET DATEFORMAT mdy;
SELECT ISDATE('15/04/2008'); --Returns 0.
SET DATEFORMAT mdy;
SELECT ISDATE('15/2008/04'); --Returns 0.
SET DATEFORMAT mdy;
SELECT ISDATE('2008/15/04'); --Returns 0.
SET DATEFORMAT mdy;
SELECT ISDATE('2008/04/15'); --Returns 1.

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

Error: User Rate Limit ExceededError: User Rate Limit Exceeded

Error: User Rate Limit ExceededprobablyError: User Rate Limit Exceededset language british;Error: User Rate Limit Exceeded Damien_The_Unbeliever
Error: User Rate Limit Exceeded0Error: User Rate Limit Exceeded juergen d
Error: User Rate Limit Exceeded Mitch Wheat

Ваш Ответ

2   ответа
5

Error: User Rate Limit ExceededError: User Rate Limit Exceeded

The return value of ISDATE depends on the settings set by SET DATEFORMAT, SET LANGUAGE and default language option.

Error: User Rate Limit Exceeded

Error: User Rate Limit ExceededSET LANGUAGEError: User Rate Limit ExceededSET DATEFORMAT (source)
3

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

/* Use these sessions settings. */
SET LANGUAGE us_english;
SET DATEFORMAT mdy;
/* Expression in mdy dateformat */
SELECT ISDATE('04/15/2008'); --Returns 1.
/* Expression in mdy dateformat */
SELECT ISDATE('04-15-2008'); --Returns 1. 
/* Expression in mdy dateformat */
SELECT ISDATE('04.15.2008'); --Returns 1. 
/* Expression in myd  dateformat */
SELECT ISDATE('04/2008/15'); --Returns 1.

SET DATEFORMAT mdy;
SELECT ISDATE('15/04/2008'); --Returns 0.
SET DATEFORMAT mdy;
SELECT ISDATE('15/2008/04'); --Returns 0.
SET DATEFORMAT mdy;
SELECT ISDATE('2008/15/04'); --Returns 0.
SET DATEFORMAT mdy;
SELECT ISDATE('2008/04/15'); --Returns 1.

SET DATEFORMAT dmy;
SELECT ISDATE('15/04/2008'); --Returns 1.
SET DATEFORMAT dym;
SELECT ISDATE('15/2008/04'); --Returns 1.
SET DATEFORMAT ydm;
SELECT ISDATE('2008/15/04'); --Returns 1.
SET DATEFORMAT ymd;
SELECT ISDATE('2008/04/15'); --Returns 1.

SET LANGUAGE English;
SELECT ISDATE('15/04/2008'); --Returns 0.
SET LANGUAGE Hungarian;
SELECT ISDATE('15/2008/04'); --Returns 0.
SET LANGUAGE Swedish;
SELECT ISDATE('2008/15/04'); --Returns 0.
SET LANGUAGE Italian;
SELECT ISDATE('2008/04/15'); --Returns 1.

/* Return to these sessions settings. */
SET LANGUAGE us_english;
SET DATEFORMAT mdy;

Error: User Rate Limit Exceeded

SET LANGUAGE us_english 
SELECT CAST('2003-02-28' AS datetime) 
-----------------------
2003-02-28 00:00:00.000

SET LANGUAGE british 
SELECT CAST('2003-02-28' AS datetime) 
Server: Msg 242, Level 16, State 3, Line 4
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.

Error: User Rate Limit Exceeded

Error: User Rate Limit ExceededYYYYMMDDError: User Rate Limit ExceededYYYY-MM-DDThh:mm:ssError: User Rate Limit ExceededTError: User Rate Limit ExceededTError: User Rate Limit Exceeded

Похожие вопросы