January 2, 2013 at 9:40 pm
Comments posted to this topic are about the item New Year's Math
January 2, 2013 at 10:09 pm
Nice one...nothing complex.. need to read the Qstn with patience...
--
Dineshbabu
--
Dineshbabu
Desire to learn new things..
January 2, 2013 at 10:36 pm
Thanks for the question.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
January 2, 2013 at 11:05 pm
Yes, Patience is the key..
nice question.. too much to read though. 🙂
~ demonfox
___________________________________________________________________
Wondering what I would do next , when I am done with this one :ermm:
January 2, 2013 at 11:56 pm
This was removed by the editor as SPAM
January 2, 2013 at 11:58 pm
Nice question Thanks. 🙂
January 3, 2013 at 12:19 am
Nice question and great explanation - didn't know about the literals in the declaration, so thanks for that too.
January 3, 2013 at 2:17 am
I got it right because although I couldn't be bothered working through the code, it was clearly adding lots of things to @NewYearsEve so the answer was never going to be either @NewYearsEve or @NewYearsDay. As there was no syntax error, that left only one possibility 🙂
January 3, 2013 at 2:52 am
I got this one fine as I have done lots of date time manipulation in SQL and other languages, but I'll happily admit the explanation put an interesting new (for me) perspective on the DATEADD and DATEDIFF functions. Nice one, cheers.
January 3, 2013 at 6:18 am
Thanks for the question.
January 3, 2013 at 8:54 am
Good topic for a question. However since I always try to get the answer without running the code I tend to really dislike questions with this level of nested logic. I am horrible at being a sql engine but pretty decent at deciphering code. I was unable to keep focus long enough to decipher the overly complicated query. I think you could have presented the idea with a far less complicated query.
That being said the explanation was good and it is always good to have a refresher on how these functions work. Thanks for the question.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
January 3, 2013 at 9:09 am
I solved it like Toreador, but at the same time I found the explanation about the literals interesting.
thanks for the question!
January 3, 2013 at 9:52 am
Interesting question -- I figured out the date math but had to find what that ODBC syntax was about. There is always something new or so far unexplored to learn. Thanks!
January 3, 2013 at 6:15 pm
Nice question. I enjoyed it.
The "flying duck" code layout made it easy to check that the parentheses matched up, so could see easily that there was no syntax error unless it was caused by those strange literals. So I had to find out what those strange literals were before going any further. First I hit on Date, Time, and Timestamp Literals but the nasty typo on that page ("-type" for "literal-type") confused me so I looked further and found Date, Time, and Timestamp Escape Sequences which gave me what I needed (and showed clearly that my confusion with the earlier page was due to a typo) so now I knew there wasn't a syntax error.
So then I could follow a process much like what some others have mentioned. Since a lot of things were added, all integer multiples of one second and none of them zero, the miliseconds in the result had to be the same as in the starting point (non-zero) and the resulting datetime had to be greater than the starting point - so only one of the options fitted the bill. No need to do any arithmetic - but it made me think!
Tom
January 4, 2013 at 1:31 am
Very interesting question. But a lot of reading 😀
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
Viewing 15 posts - 1 through 15 (of 15 total)
You must be logged in to reply to this topic. Login to reply