Today's Random Word!

  • 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)


    mutiny

    How 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...

  • SELECT DATEDIFF(dd,GetDate(),'12/25/11') AS DaysTillChristmas

  • Horse-hockey (R.I.P. Harry Morgan)

    +--------------------------------------------------------------------------------------+
    Check out my blog at https://pianorayk.wordpress.com/

  • 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


    Forever trying to learn
    My blog - http://www.cadavre.co.uk/
    For better, quicker answers on T-SQL questions, click on the following...http://www.sqlservercentral.com/articles/Best+Practices/61537/
    For better, quicker answers on SQL Server performance related questions, click on the following...http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

  • Cadavre (12/8/2011)


    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

    Sometimes I wonder if I spend too much time on these forums......:-P

  • Daniel Bowlin (12/8/2011)


    Cadavre (12/8/2011)


    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

    Sometimes I wonder if I spend too much time on these forums......:-P

    Just asking the question is answering it :hehe:.

  • Daniel Bowlin (12/8/2011)


    Cadavre (12/8/2011)


    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

    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

  • 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


    Forever trying to learn
    My blog - http://www.cadavre.co.uk/
    For better, quicker answers on T-SQL questions, click on the following...http://www.sqlservercentral.com/articles/Best+Practices/61537/
    For better, quicker answers on SQL Server performance related questions, click on the following...http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

  • WOTD - Gnu

  • 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

  • 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

  • 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)_ \


    Forever trying to learn
    My blog - http://www.cadavre.co.uk/
    For better, quicker answers on T-SQL questions, click on the following...http://www.sqlservercentral.com/articles/Best+Practices/61537/
    For better, quicker answers on SQL Server performance related questions, click on the following...http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

  • 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

  • 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

  • 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