SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Interesting Datenames


Interesting Datenames

Author
Message
Steve Jones
Steve Jones
SSC Guru
SSC Guru (280K reputation)SSC Guru (280K reputation)SSC Guru (280K reputation)SSC Guru (280K reputation)SSC Guru (280K reputation)SSC Guru (280K reputation)SSC Guru (280K reputation)SSC Guru (280K reputation)

Group: Administrators
Points: 280672 Visits: 19901
Comments posted to this topic are about the item Interesting Datenames

Follow me on Twitter: @way0utwest
Forum Etiquette: How to post data/code on a forum to get the best help
My Blog: www.voiceofthedba.com
Louis Hillebrand
Louis Hillebrand
SSCrazy
SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)

Group: General Forum Members
Points: 2325 Visits: 3651
Setting the date is depending on the language/region setting of SQL server.
he server I tested on interpreted the string '10/02/17' as February 10th, DATENAME returned 10.
I picked the wrong answer.

Louis.
HappyGeek
HappyGeek
SSCertifiable
SSCertifiable (5.6K reputation)SSCertifiable (5.6K reputation)SSCertifiable (5.6K reputation)SSCertifiable (5.6K reputation)SSCertifiable (5.6K reputation)SSCertifiable (5.6K reputation)SSCertifiable (5.6K reputation)SSCertifiable (5.6K reputation)

Group: General Forum Members
Points: 5617 Visits: 3081

Good question, thanks Steve.



...
Stewart "Arturius" Campbell
Stewart "Arturius" Campbell
SSC-Dedicated
SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)

Group: General Forum Members
Points: 30716 Visits: 7612
The database i tested my answer on has "us_english" as the default language.
the script would therefore interpret the date provided as MM/dd/yyyy

Interestingly, if the SET LANGUAGE British was placed at the top of the script, the date would be interpreted as dd/MM/yyyy...

Language settings are important....

____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
Toreador
Toreador
SSCertifiable
SSCertifiable (5.4K reputation)SSCertifiable (5.4K reputation)SSCertifiable (5.4K reputation)SSCertifiable (5.4K reputation)SSCertifiable (5.4K reputation)SSCertifiable (5.4K reputation)SSCertifiable (5.4K reputation)SSCertifiable (5.4K reputation)

Group: General Forum Members
Points: 5373 Visits: 8220

The correct answer is not 02, it is 2...


Andy Robertson
Andy Robertson
Ten Centuries
Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)

Group: General Forum Members
Points: 1181 Visits: 254

Oops.... missed that the default was US_English (dozy berk)!


carl.eaves
carl.eaves
SSC-Enthusiastic
SSC-Enthusiastic (177 reputation)SSC-Enthusiastic (177 reputation)SSC-Enthusiastic (177 reputation)SSC-Enthusiastic (177 reputation)SSC-Enthusiastic (177 reputation)SSC-Enthusiastic (177 reputation)SSC-Enthusiastic (177 reputation)SSC-Enthusiastic (177 reputation)

Group: General Forum Members
Points: 177 Visits: 78
Got it right, but only because I deliberately put the wrong answer.
There are people on here who live and work outside the US with their illogical date format.
Stewart "Arturius" Campbell
Stewart "Arturius" Campbell
SSC-Dedicated
SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)

Group: General Forum Members
Points: 30716 Visits: 7612
carl.eaves - Tuesday, November 14, 2017 2:44 AM
Got it right, but only because I deliberately put the wrong answer.
There are people on here who live and work outside the US with their illogical date format.


I'm one of those that live outside the US. However, my current contract involves working with a company that spans several continents, each with their own date format peculiarities...

____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
Mighty
Mighty
SSCertifiable
SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)

Group: General Forum Members
Points: 5747 Visits: 1837
Something that might not be clear is that only the date format is not changed until the end of the batch. What the DATENAME returns is directly affected.

DECLARE @RunDate DATE = '10/02/17'
SET LANGUAGE Italian
SELECT DATENAME(dd, @RunDate)
SELECT DATENAME(MONTH, @RunDate)
SET LANGUAGE US_English
SELECT DATENAME(dd, @RunDate)
SELECT DATENAME(MONTH, @RunDate)

For me that feels a bit inconsistent.

Ed Wagner
Ed Wagner
SSC Guru
SSC Guru (129K reputation)SSC Guru (129K reputation)SSC Guru (129K reputation)SSC Guru (129K reputation)SSC Guru (129K reputation)SSC Guru (129K reputation)SSC Guru (129K reputation)SSC Guru (129K reputation)

Group: General Forum Members
Points: 129037 Visits: 11394
Stewart "Arturius" Campbell - Tuesday, November 14, 2017 2:49 AM
carl.eaves - Tuesday, November 14, 2017 2:44 AM
Got it right, but only because I deliberately put the wrong answer.
There are people on here who live and work outside the US with their illogical date format.


I'm one of those that live outside the US. However, my current contract involves working with a company that spans several continents, each with their own date format peculiarities...

I live and work in the US, but have the privilege of working with data for many different countries. There are a lot of date formats out there and the same applies to strange number formats. Customers in different countries don't always follow their own standards. If you have to work with global data, then it's a normal part of daily life.



Tally Tables - Performance Personified
String Splitting with True Performance
Best practices on how to ask questions
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum







































































































































































SQLServerCentral


Search