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»»»

Predict the total count Expand / Collapse
Author
Message
Posted Friday, November 5, 2010 2:53 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 4:02 PM
Points: 6,133, Visits: 8,396
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
Post #1016416
Posted Friday, November 5, 2010 3:17 AM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Monday, December 15, 2014 1:36 AM
Points: 1,594, Visits: 438
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.
Post #1016419
Posted Friday, November 5, 2010 3:20 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, April 3, 2014 9:52 AM
Points: 1,319, Visits: 176
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.

Post #1016420
Posted Friday, November 5, 2010 3:25 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Thursday, June 5, 2014 3:11 AM
Points: 46, Visits: 26
Like selyod, with Italian settings (dd/mm/yyyy) this statement return 1
Post #1016422
Posted Friday, November 5, 2010 3:31 AM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: 2 days ago @ 10:22 AM
Points: 1,830, Visits: 6,646
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?
Post #1016423
Posted Friday, November 5, 2010 3:41 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, November 27, 2014 5:23 AM
Points: 1,425, Visits: 1,316
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
Post #1016426
Posted Friday, November 5, 2010 3:45 AM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Friday, December 12, 2014 3:32 AM
Points: 1,639, Visits: 5,721
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?
Post #1016427
Posted Friday, November 5, 2010 3:47 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Yesterday @ 12:49 AM
Points: 2,620, Visits: 2,467
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

Post #1016428
Posted Friday, November 5, 2010 3:53 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, November 27, 2014 5:23 AM
Points: 1,425, Visits: 1,316
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
Post #1016431
Posted Friday, November 5, 2010 6:36 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Yesterday @ 9:53 AM
Points: 2,667, Visits: 4,091
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.
Post #1016484
« Prev Topic | Next Topic »

Add to briefcase ««12345»»»

Permissions Expand / Collapse