Fun with Dates

  • Comments posted to this topic are about the item Fun with Dates

  • Nice little puzzle to end the week on, thanks Steve.

    ...

  • But why: 

    SELECT  IsNull = 'Isnull'

    ?

  • Nice question to end the week on, thanks Steve

    RoNoS - Friday, October 27, 2017 2:02 AM

    But why: 

    SELECT  IsNull = 'Isnull'

    ?

    This happens when implicit conversion takes place (in this case DATE to DATETIME)
    try this:
    DECLARE @MyDate DATE, @MyDateTime DATETIME = GETDATE();
    SET @MyDate = @MyDateTime;
    IF @MyDate = @MyDateTime
    BEGIN
    SELECT "The variables match"
    END
    ELSE
    BEGIN
    SELECT "No way these variables match"
    END

    ____________________________________________
    Space, the final frontier? not any more...
    All limits henceforth are self-imposed.
    “libera tute vulgaris ex”

  • Actually, Ii think the answer should have been "The parameter @dt is the wrong data type"

    Michael L John
    If you assassinate a DBA, would you pull a trigger?
    To properly post on a forum:
    http://www.sqlservercentral.com/articles/61537/

  • RoNoS - Friday, October 27, 2017 2:02 AM

    But why: 

    SELECT  IsNull = 'Isnull'

    ?

    Heh... I can't know for sure because I can't read Steve's mind but I'm thinking that it was a huge hint. 😉

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply