SQL Server English date to general date format

Time:2020-10-30

Question:

The English date format is converted to the general date format. In the Chinese environment, if the conversion script is executed directly, an error will be reported
Message 241, level 16, status 1, line 1
Conversion failed when converting date and / or time from string.

Root cause:

The English date format does not count as a date format in Chinese, but only in English.

Solution:

Set language us is required_ English settings

script:

/*
Author: zhang502219048
Script source: https://www.cnblogs.com/zhang502219048/p/13616995.html
*/

/*
To convert English date format into general date format, set language US needs to be added in Chinese environment_ Set English, otherwise an error will be reported
Message 241, level 16, status 1, line 1
Conversion failed when converting date and / or time from string.
*/
set language US_ENGLISH
select cast('Jun 20 2020  4:08PM' as datetime)

Script run results:

[please indicate the source of the blog: https://www.cnblogs.com/zhang502219048/p/13616995.html ]

Recommended Today

Go learning notes map (Dictionary)

1. Declaration assignment: var m1 map[string]int m1 = map[string]int{“name”:1, “xxx”:2} be equal to m1 := make(map[string]int) be equal to m1 := map[string]int{} //m2 := map[string]interface{}{} 2. Map is a reference type m2 := m1 m2[“age”] = 18 //Results of M1: Map[ age:18 name 1 xxx:2 ] 3. Determine whether the map value exists OK, it’s […]