|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 2:13 PM
Points: 5,237,
Visits: 7,044
|
|
Terrible question. The only correct answer is "it depends", and that answer was missing.
If the default language of your server happens to be, for example, British English, you'll get 1 as your answer. Same for German, Dutch, French, and several other languages.
Add this to the fact that it's impossible to know what date the number 40358 represents, and you get a question that is impossible to answer without running the code, and even after running it leaves you with a choice between two answers.
(I used an educated guess - in my experience, over 90% of the code that does not cater for international use comes from the US, so I picked the answer I got when using SET LANGUAGE us_english)
Please do submit more questions in the future - but not of this quality.
Hugo Kornelis, SQL Server MVP Visit my SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Today @ 8:21 AM
Points: 1,052,
Visits: 316
|
|
| Both 1 and 2 are the correct answer depending of the Dateformat set!. As others has said a poor question unless we have SET DATEFORMAT at the start.
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Monday, May 13, 2013 8:31 AM
Points: 1,038,
Visits: 121
|
|
Poor US-centric question. The answer is dependent upon the cultural settings of your server.
Remember the rest of the world does not share this irrational date format. We on the whole use either day/month/year or year/month/day. Plus how is anyone supposed to know what date 40358 relates to without running a query?
See me after class - must try harder.
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Thursday, November 17, 2011 3:03 AM
Points: 46,
Visits: 23
|
|
| Like selyod, with Italian settings (dd/mm/yyyy) this statement return 1
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Friday, May 17, 2013 9:52 AM
Points: 1,356,
Visits: 4,761
|
|
| Even ignoring the date format problem, what is this question supposed to teach us? Why would anyone want to convert a date to a float?
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Yesterday @ 6:14 AM
Points: 1,102,
Visits: 1,197
|
|
Hugo Kornelis (11/5/2010)
(I used an educated guess - in my experience, over 90% of the code that does not cater for international use comes from the US, so I picked the answer I got when using SET LANGUAGE us_english)
I used the same tactics. If somone don't take care of other languages, he is often English speaking, and USA is a good quess.
See, understand, learn, try, use efficient © Dr.Plch
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Today @ 9:30 AM
Points: 1,257,
Visits: 4,257
|
|
| I knew when I saw it that this question was going to rely on a particular date format being the default...surely that sort of thing should be checked before they're posted?
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: Today @ 1:51 AM
Points: 1,971,
Visits: 1,821
|
|
So when the conversion into floats and then taking ceiling of the values, these 2 records generate the same values. I disagree with explanation, it's enough to convert to INT
Select count(intField) from TableDate where convert(INT,datefield) = 40358
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Yesterday @ 6:14 AM
Points: 1,102,
Visits: 1,197
|
|
Most of complainers: The problem is not dd/mm/yyyy against mm/dd/yyyy as both combinations are inserted (First of July and Seventh of January). Problem is in yyyy/dd/mm against yyyy/mm/dd. And both of them are valid.
Why convert datetime to float? I don't know. Because it is permitted?
See, understand, learn, try, use efficient © Dr.Plch
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Today @ 12:55 PM
Points: 2,015,
Visits: 2,847
|
|
This is an odd question. I instantly recognized 40358 as the "hundred-year format" date used by Infinium software on the AS400. I ran 40358 against the converter and returned 6/30/2010. Why would the two platforms differ by one day?
I agree with others that 40358 is odd to have in the question and why would anyone use it instead of a real date if they don't have to. I'm forced to deal with it in the Infinium software but I wouldn't choose to.
|
|
|
|