December 7, 2011 at 12:16 pm
Revenant (12/7/2011)
SQLRNNR (12/7/2011)
Ninja's_RGR'us (12/7/2011)
SQLRNNR (12/7/2011)
bcsims 90437 (12/7/2011)
Ninja's_RGR'us (12/7/2011)
SQLRNNR (12/7/2011)
mutinyHow can you do that when you're the boss???
Multiple personalities?
understatement
says who?
Legion
Foreign?
March or Die - Great Foreign Legion film with Gene Hackman...
December 7, 2011 at 1:00 pm
SELECT DATEDIFF(dd,GetDate(),'12/25/11') AS DaysTillChristmas
December 7, 2011 at 2:02 pm
Horse-hockey (R.I.P. Harry Morgan)
+--------------------------------------------------------------------------------------+
Check out my blog at https://pianorayk.wordpress.com/
December 8, 2011 at 5:44 am
Daniel Bowlin (12/7/2011)
SELECT DATEDIFF(dd,GetDate(),'12/25/11') AS DaysTillChristmas
Just to over-complicate matters . . . π
SELECT CASE WHEN GETDATE() > DATEADD(d, 24, DATEADD(m, 11, DATEADD(yy, DATEDIFF(yy, 0, GETDATE()), 0)))
THEN DATEDIFF(dd,GETDATE(),DATEADD(d, 24, DATEADD(m, 11, DATEADD(yy, DATEDIFF(yy, 0, GETDATE()) + 1, 0))))
WHEN GETDATE() < DATEADD(d, 24, DATEADD(m, 11, DATEADD(yy, DATEDIFF(yy, 0, GETDATE()), 0)))
THEN DATEDIFF(dd,GETDATE(),DATEADD(d, 24, DATEADD(m, 11, DATEADD(yy, DATEDIFF(yy, 0, GETDATE()), 0))))
ELSE 0 END AS DaysTillChristmas
December 8, 2011 at 7:15 am
Cadavre (12/8/2011)
Daniel Bowlin (12/7/2011)
SELECT DATEDIFF(dd,GetDate(),'12/25/11') AS DaysTillChristmasJust to over-complicate matters . . . π
SELECT CASE WHEN GETDATE() > DATEADD(d, 24, DATEADD(m, 11, DATEADD(yy, DATEDIFF(yy, 0, GETDATE()), 0)))
THEN DATEDIFF(dd,GETDATE(),DATEADD(d, 24, DATEADD(m, 11, DATEADD(yy, DATEDIFF(yy, 0, GETDATE()) + 1, 0))))
WHEN GETDATE() < DATEADD(d, 24, DATEADD(m, 11, DATEADD(yy, DATEDIFF(yy, 0, GETDATE()), 0)))
THEN DATEDIFF(dd,GETDATE(),DATEADD(d, 24, DATEADD(m, 11, DATEADD(yy, DATEDIFF(yy, 0, GETDATE()), 0))))
ELSE 0 END AS DaysTillChristmas
Sometimes I wonder if I spend too much time on these forums......:-P
December 8, 2011 at 7:23 am
Daniel Bowlin (12/8/2011)
Cadavre (12/8/2011)
Daniel Bowlin (12/7/2011)
SELECT DATEDIFF(dd,GetDate(),'12/25/11') AS DaysTillChristmasJust to over-complicate matters . . . π
SELECT CASE WHEN GETDATE() > DATEADD(d, 24, DATEADD(m, 11, DATEADD(yy, DATEDIFF(yy, 0, GETDATE()), 0)))
THEN DATEDIFF(dd,GETDATE(),DATEADD(d, 24, DATEADD(m, 11, DATEADD(yy, DATEDIFF(yy, 0, GETDATE()) + 1, 0))))
WHEN GETDATE() < DATEADD(d, 24, DATEADD(m, 11, DATEADD(yy, DATEDIFF(yy, 0, GETDATE()), 0)))
THEN DATEDIFF(dd,GETDATE(),DATEADD(d, 24, DATEADD(m, 11, DATEADD(yy, DATEDIFF(yy, 0, GETDATE()), 0))))
ELSE 0 END AS DaysTillChristmas
Sometimes I wonder if I spend too much time on these forums......:-P
Just asking the question is answering it :hehe:.
December 8, 2011 at 7:56 am
Daniel Bowlin (12/8/2011)
Cadavre (12/8/2011)
Daniel Bowlin (12/7/2011)
SELECT DATEDIFF(dd,GetDate(),'12/25/11') AS DaysTillChristmasJust to over-complicate matters . . . π
SELECT CASE WHEN GETDATE() > DATEADD(d, 24, DATEADD(m, 11, DATEADD(yy, DATEDIFF(yy, 0, GETDATE()), 0)))
THEN DATEDIFF(dd,GETDATE(),DATEADD(d, 24, DATEADD(m, 11, DATEADD(yy, DATEDIFF(yy, 0, GETDATE()) + 1, 0))))
WHEN GETDATE() < DATEADD(d, 24, DATEADD(m, 11, DATEADD(yy, DATEDIFF(yy, 0, GETDATE()), 0)))
THEN DATEDIFF(dd,GETDATE(),DATEADD(d, 24, DATEADD(m, 11, DATEADD(yy, DATEDIFF(yy, 0, GETDATE()), 0))))
ELSE 0 END AS DaysTillChristmas
Sometimes I wonder if I spend too much time on these forums......:-P
Obviously not enough. You didn't notice the bug in that code π - on Christmas morning it only gives the correct (0) answer for the couple of milliseconds, and then it says 366 for teh rest of the day.
This would be better:SELECT CASE WHEN cast(GETDATE() as DATE) > DATEADD(d, 24, DATEADD(m, 11, DATEADD(yy, DATEDIFF(yy, 0, cast(GETDATE() as DATE)), 0)))
THEN DATEDIFF(dd,cast(GETDATE() as DATE),DATEADD(d, 24, DATEADD(m, 11, DATEADD(yy, DATEDIFF(yy, 0, cast(GETDATE() as DATE)) + 1, 0))))
WHEN cast(GETDATE() as DATE) < DATEADD(d, 24, DATEADD(m, 11, DATEADD(yy, DATEDIFF(yy, 0, cast(GETDATE() as DATE)), 0)))
THEN DATEDIFF(dd,cast(GETDATE() as DATE),DATEADD(d, 24, DATEADD(m, 11, DATEADD(yy, DATEDIFF(yy, 0, cast(GETDATE() as DATE)), 0))))
ELSE 0 END AS DaysTillChristmas[/quote]
<Pedantic nonsense>Anyway, don't you mean "fora"? "forums" isn't a word.</Pedantic nonsense> :w00t:
Tom
December 8, 2011 at 8:09 am
L' Eomot InversΓ© (12/8/2011)
Obviously not enough. You didn't notice the bug in that code π - on Christmas morning it only gives the correct (0) answer for the couple of milliseconds, and then it says 366 for teh rest of the day.This would be better:
SELECT CASE WHEN cast(GETDATE() as DATE) > DATEADD(d, 24, DATEADD(m, 11, DATEADD(yy, DATEDIFF(yy, 0, cast(GETDATE() as DATE)), 0)))
THEN DATEDIFF(dd,cast(GETDATE() as DATE),DATEADD(d, 24, DATEADD(m, 11, DATEADD(yy, DATEDIFF(yy, 0, cast(GETDATE() as DATE)) + 1, 0))))
WHEN cast(GETDATE() as DATE) < DATEADD(d, 24, DATEADD(m, 11, DATEADD(yy, DATEDIFF(yy, 0, cast(GETDATE() as DATE)), 0)))
THEN DATEDIFF(dd,cast(GETDATE() as DATE),DATEADD(d, 24, DATEADD(m, 11, DATEADD(yy, DATEDIFF(yy, 0, cast(GETDATE() as DATE)), 0))))
ELSE 0 END AS DaysTillChristmas
<Pedantic nonsense>Anyway, don't you mean "fora"? "forums" isn't a word.</Pedantic nonsense> :w00t:
Boo, missed that π
Here's my fixed version: -
SELECT CASE WHEN GETDATE() > DATEADD(d, 25, DATEADD(m, 11, DATEADD(yy, DATEDIFF(yy, 0, GETDATE()), 0)))
THEN DATEDIFF(dd,GETDATE(),DATEADD(d, 24, DATEADD(m, 11, DATEADD(yy, DATEDIFF(yy, 0, GETDATE()) + 1, 0))))
WHEN GETDATE() < DATEADD(d, 25, DATEADD(m, 11, DATEADD(yy, DATEDIFF(yy, 0, GETDATE()), 0)))
THEN DATEDIFF(dd,GETDATE(),DATEADD(d, 24, DATEADD(m, 11, DATEADD(yy, DATEDIFF(yy, 0, GETDATE()), 0))))
ELSE 0 END AS DaysTillChristmas
December 8, 2011 at 8:33 am
WOTD - Gnu
December 8, 2011 at 8:40 am
Cadavre (12/8/2011)
L' Eomot InversΓ© (12/8/2011)
Obviously not enough. You didn't notice the bug in that code π - on Christmas morning it only gives the correct (0) answer for the couple of milliseconds, and then it says 366 for teh rest of the day.This would be better:
SELECT CASE WHEN cast(GETDATE() as DATE) > DATEADD(d, 24, DATEADD(m, 11, DATEADD(yy, DATEDIFF(yy, 0, cast(GETDATE() as DATE)), 0)))
THEN DATEDIFF(dd,cast(GETDATE() as DATE),DATEADD(d, 24, DATEADD(m, 11, DATEADD(yy, DATEDIFF(yy, 0, cast(GETDATE() as DATE)) + 1, 0))))
WHEN cast(GETDATE() as DATE) < DATEADD(d, 24, DATEADD(m, 11, DATEADD(yy, DATEDIFF(yy, 0, cast(GETDATE() as DATE)), 0)))
THEN DATEDIFF(dd,cast(GETDATE() as DATE),DATEADD(d, 24, DATEADD(m, 11, DATEADD(yy, DATEDIFF(yy, 0, cast(GETDATE() as DATE)), 0))))
ELSE 0 END AS DaysTillChristmas
<Pedantic nonsense>Anyway, don't you mean "fora"? "forums" isn't a word.</Pedantic nonsense> :w00t:
Boo, missed that π
Here's my fixed version: -
SELECT CASE WHEN GETDATE() > DATEADD(d, 25, DATEADD(m, 11, DATEADD(yy, DATEDIFF(yy, 0, GETDATE()), 0)))
THEN DATEDIFF(dd,GETDATE(),DATEADD(d, 24, DATEADD(m, 11, DATEADD(yy, DATEDIFF(yy, 0, GETDATE()) + 1, 0))))
WHEN GETDATE() < DATEADD(d, 25, DATEADD(m, 11, DATEADD(yy, DATEDIFF(yy, 0, GETDATE()), 0)))
THEN DATEDIFF(dd,GETDATE(),DATEADD(d, 24, DATEADD(m, 11, DATEADD(yy, DATEDIFF(yy, 0, GETDATE()), 0))))
ELSE 0 END AS DaysTillChristmas
Yay. Now I know for sure that there are only 17 days until Christmas.
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
December 8, 2011 at 8:41 am
crookj (12/8/2011)
WOTD - Gnu
Gnu News
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
December 8, 2011 at 9:25 am
SQLRNNR (12/8/2011)
Yay. Now I know for sure that there are only 17 days until Christmas.
And knowing is half the battle.
/@
\ ___> (__O) (____@) (____@) (__o)_ \
December 8, 2011 at 9:41 am
Cadavre (12/8/2011)
SQLRNNR (12/8/2011)
Yay. Now I know for sure that there are only 17 days until Christmas.And knowing is half the battle.
time
/@
\ ___> (__O) (____@) (____@) (__o)_ \
Ok, I like it - but somebody has a lot of time on their hand.
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
December 8, 2011 at 10:11 am
Cadavre (12/8/2011)
Boo, missed that πHere's my fixed version: -
<code snipped>
Drat, I missed out 6 casts ("0" changed to "cast(cast 0 as datetime) as date)" in three places! :blush: I was planning to wait for you (or anyone) to come up with the 24 -> 25 solution and then I could make a pedantic claim that one should use DATE not DATETIME to do date comparisons, but when it came to it I noticed that in fact I was still using datetime mostly. I can't even get the pedantry right when I'm trying to clown with it. Where's the face-palm icon?
Tom
December 8, 2011 at 11:07 am
L' Eomot InversΓ© (12/8/2011)
Cadavre (12/8/2011)
Boo, missed that πHere's my fixed version: -
<code snipped>
Drat, I missed out 6 casts ("0" changed to "cast(cast 0 as datetime) as date)" in three places! :blush: I was planning to wait for you (or anyone) to come up with the 24 -> 25 solution and then I could make a pedantic claim that one should use DATE not DATETIME to do date comparisons, but when it came to it I noticed that in fact I was still using datetime mostly. I can't even get the pedantry right when I'm trying to clown with it. Where's the face-palm icon?
Fits well with your new Avatar.
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
Viewing 15 posts - 5,551 through 5,565 (of 21,190 total)
You must be logged in to reply to this topic. Login to reply