Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12345»»»

Date Puzzle Expand / Collapse
Author
Message
Posted Wednesday, October 27, 2010 2:44 AM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Yesterday @ 10:20 AM
Points: 1,740, Visits: 6,366
Hugo Kornelis (10/27/2010)
For the datetime data type, The only formats that are guaranteed to work correctly in all circumstances are:
* yyyymmdd - for dates without time portion. No dashes. dots, slashes or other punctuation. The resulting datetime value will have its time portion set to midnight.


We use yyyy-mm-dd which has always worked so far.
Should I be worried?!
Post #1011337
Posted Wednesday, October 27, 2010 3:08 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Tuesday, August 27, 2013 4:28 AM
Points: 1,248, Visits: 779
I'm absolutely gob smacked somebody answered 29Apr, or even worse 31Mar.

I'll give them the benefit of the doubt though and presume they suspected a trick question.

Agree with the previous poster that 30Apr, 31Apr, 1May would have been more teasing options.

Good question though, I like the easy ones... coz I can answer those


_____________________________________________________________________
"The difficult tasks we do immediately, the impossible takes a little longer"
Post #1011347
Posted Wednesday, October 27, 2010 3:40 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 1:14 PM
Points: 5,977, Visits: 8,237
Toreador (10/27/2010)
Hugo Kornelis (10/27/2010)
For the datetime data type, The only formats that are guaranteed to work correctly in all circumstances are:
* yyyymmdd - for dates without time portion. No dashes. dots, slashes or other punctuation. The resulting datetime value will have its time portion set to midnight.


We use yyyy-mm-dd which has always worked so far.
Should I be worried?!

set language German;
select cast('2010-10-27' as datetime);
select cast('20101027' as datetime);

Die Spracheneinstellung wurde auf Deutsch geändert.

-----------------------
Msg 242, Level 16, State 3, Line 2
Bei der Konvertierung eines char-Datentyps in einen datetime-Datentyp liegt der datetime-Wert außerhalb des gültigen Bereichs.


-----------------------
2010-10-27 00:00:00.000

German was the first of the languages I tested that returned an error when using yyyy-mm-dd. I did not try the remaining languages. You can easily do that for yourself.
(For a list of possible languages, run "select * from sys.syslanguages;", and use either the "name" or the "alias" column as argument for SET LANGUAGE).



Hugo Kornelis, SQL Server MVP
Visit my SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
Post #1011352
Posted Wednesday, October 27, 2010 7:28 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, August 27, 2014 9:45 PM
Points: 132, Visits: 212
easy question
Post #1011519
Posted Wednesday, October 27, 2010 7:33 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, January 31, 2013 8:01 AM
Points: 1,232, Visits: 1,046
I give this question Five Stars!

It was code correct, the question was clear and had no typo's, and the author clearly understood the concept his question was testing.

This Question of the Day has been plagued lately with poorly worded and misspelled code examples and questions. That along with the fact they they were complex questions with complex SQL Server features and statements made them horible.
Post #1011525
Posted Wednesday, October 27, 2010 7:34 AM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Yesterday @ 10:20 AM
Points: 1,740, Visits: 6,366
Fortuntely I was fibbing and we actually convert to proper dates before passing to SQLServer
Post #1011529
Posted Wednesday, October 27, 2010 7:45 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 10:46 AM
Points: 13,622, Visits: 10,513
SanDroid (10/27/2010)
I give this question Five Stars!

It was code correct, the question was clear and had no typo's, and the author clearly understood the concept his question was testing.

This Question of the Day has been plagued lately with poorly worded and misspelled code examples and questions. That along with the fact they they were complex questions with complex SQL Server features and statements made them horible.


All I am reading is: easy question = good, difficult question = bad




How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?

Member of LinkedIn. My blog at LessThanDot.

MCSA SQL Server 2012 - MCSE Business Intelligence
Post #1011537
Posted Wednesday, October 27, 2010 8:27 AM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Yesterday @ 9:16 AM
Points: 1,632, Visits: 5,585
DougieCow (10/27/2010)
I'm absolutely gob smacked somebody answered 29Apr, or even worse 31Mar.


I'm kind of baffled anyone would have picked 29-Apr too--there's actually some logic to picking 31-Mar, but 29th April?
Post #1011582
Posted Wednesday, October 27, 2010 8:50 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, January 31, 2013 8:01 AM
Points: 1,232, Visits: 1,046
da-zero (10/27/2010)

All I am reading is: easy question = good, difficult question = bad


I can tell by your reading and writing level you might be the moderator checking the questions before posting them.
Suggestion, actually try to execute the code and check for errors. This is the first QOTD I have looked at this month that didn't have any.

Is that easy or difficult for you to understand?
Post #1011611
Posted Wednesday, October 27, 2010 9:12 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 1:14 PM
Points: 5,977, Visits: 8,237
SanDroid (10/27/2010)
da-zero (10/27/2010)

All I am reading is: easy question = good, difficult question = bad


I can tell by your reading and writing level you might be the moderator checking the questions before posting them.
Suggestion, actually try to execute the code and check for errors. This is the first QOTD I have looked at this month that didn't have any.

Is that easy or difficult for you to understand?

The only people who review the questions are the question author (Abhijit for this question), and Steve Jones. And Steve often lacks the time to properly check the questions. So your assessment of da-zero is wrong.

I do not agree with the comment da-zero made to your post. But I also disagree with your enthousiasm about this question. I do agree partly with the second sentence you wrote ("It was code correct, the question was clear and had no typo's, and the author clearly understood the concept his question was testing"), though the code was definitely not safe in non-US environments.

But I totally disagree with your final statement ("That along with the fact they they were complex questions with complex SQL Server features and statements made them horible"). These questions should provide a learning opportunity, and that will hardly happen with questions as simple as this one. I expect the QotD to be about complex and/or little-known features.
(And yes, I also expect them to be error-free -which unfortunately happens less often than I would like).



Hugo Kornelis, SQL Server MVP
Visit my SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
Post #1011635
« Prev Topic | Next Topic »

Add to briefcase ««12345»»»

Permissions Expand / Collapse