September 27, 2011 at 7:04 am
Scary question, I went with what the answer was but I was ready for a long discussion over a typo.
September 27, 2011 at 7:19 am
venoym (9/27/2011)
I thought the question was fine. The trickery would have gotten closer to an 80% failed if the possible answers had included the number 4. That was my first red flag that there was a trick when the "correct" answer was not in the answer list.
Uh, why do you think that the answer would have been four? It would have been 3 actually.
September 27, 2011 at 7:29 am
Wonderfull straightforward question. I see no trick in it.
Considering the amount of times I have seen this behavior of Between cause bug in code I was not suprised at the amount of wrong answers. 😛
Also not suprised at the amount of dissussion already.
For a successful technology, reality must take precedence over public relations, for Nature cannot be fooled.
Richard P. Feynman
😎
September 27, 2011 at 7:29 am
Thanks for the question
September 27, 2011 at 7:32 am
tricky question, went over the head. would be easier if there was < and > dates..
Didn't knew, between operator works like that too 🙁
I thought I can enter any dates irrespective of order and it will fetch the results...
Atleast i know now.
Regards,
Sushant
Regards
Sushant Kumar
MCTS,MCP
September 27, 2011 at 7:51 am
Great question. Just like real life debugging. Read carefully and avoid making incorrect assumptions.
September 27, 2011 at 8:16 am
Ha, I read the code the way I would have written it Date1 first with the lesser datetime and Date2 second with the greater datetime. My bad. Good question. There should have been a warning: "There are tricks in this code, make sure you have enough caffeine before attempting an answer"
September 27, 2011 at 8:30 am
Ola L Martins-329921 (9/27/2011)
Of course, failing the question I will argue that this question should be under the category (yet to be added) READING... 😉
That may not be a bad idea. Add a category of code review or something like that. Of course, that may invite questions where the answer is more a matter of opinion.
September 27, 2011 at 9:06 am
I agree - definitely more of a trick question. If you reverse the @DATE1 and @DATE2 in the BETWEEN query it actually makes quite an interesting question - will it return 3 or 5 rows? That's what I was trying to answer. 😀
September 27, 2011 at 9:15 am
jts_2003 (9/27/2011)
I agree - definitely more of a trick question. If you reverse the @DATE1 and @DATE2 in the BETWEEN query it actually makes quite an interesting question - will it return 3 or 5 rows? That's what I was trying to answer. 😀
Same here.
Between = >/ or </
or just
Between = > or <
Regards,
Sushant
Regards
Sushant Kumar
MCTS,MCP
September 27, 2011 at 9:16 am
jts_2003 (9/27/2011)
I agree - definitely more of a trick question. If you reverse the @DATE1 and @DATE2 in the BETWEEN query it actually makes quite an interesting question - will it return 3 or 5 rows? That's what I was trying to answer. 😀
3 rows. If you don't add a time, it assumes midnight. So the BETWEEN would be Jan 2 at midnight to Jan 4 at midnight, and only the rows for the 2nd and 3rd will be selected.
September 27, 2011 at 9:27 am
Good question, further emphasizes that you need to closely evaluate any code you're looking at.
September 27, 2011 at 9:28 am
Tricky but I got it! I acutally had a similar situation recently where I had flubbed the date parameters so this was still freshly burned into my memory! 😀
September 27, 2011 at 9:30 am
Devil is in the detail... thanks, nice QoD!
September 27, 2011 at 9:48 am
Good question - without the reversed order of the variables in the assignment of values, which was clearly designed to put a 'gotcha' into the mix. However, as many have suggested, it's a good lesson in paying attention to the details that appear to be on the periphery of the apparent problem, but which end up being the real cause of the problem.
So...a humbled thanks!
Rob Schripsema
Propack, Inc.
Viewing 15 posts - 31 through 45 (of 66 total)
You must be logged in to reply to this topic. Login to reply