More Precedence

  • Comments posted to this topic are about the item More Precedence

  • That is really interesting.
    Pity this cannot be effected on the new  datetime datatypes (e.g. datetime2)
    thanks for the question, Avinash

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

  • Is there an explanation why 0x20 (32) results in 107 milliseconds?

  • Mighty - Tuesday, November 7, 2017 1:47 AM

    Is there an explanation why 0x20 (32) results in 107 milliseconds?

    Spoiler:
    Ë™sɯㄥ0Æ– xoɹddÉ sá´‰ Çsoɥʇ ÉŸo á„…Æ ;puoÉ”Çs É ÉŸo ɥʇ00Æ/Æ– sá´‰ ÇdʎʇÉʇÉp ÇɯᴉʇÇʇÉp Çɥʇ uá´‰ Çɯᴉʇ ÉŸo uoá´‰sᴉʌᴉpqns ʇsÇllÉɯs Çɥ┴

    Thomas Rushton
    blog: https://thelonedba.wordpress.com

  • ThomasRushton - Tuesday, November 7, 2017 4:21 AM

    Mighty - Tuesday, November 7, 2017 1:47 AM

    Is there an explanation why 0x20 (32) results in 107 milliseconds?

    Spoiler:
    Ë™sɯㄥ0Æ– xoɹddÉ sá´‰ Çsoɥʇ ÉŸo á„…Æ ;puoÉ”Çs É ÉŸo ɥʇ00Æ/Æ– sá´‰ ÇdʎʇÉʇÉp ÇɯᴉʇÇʇÉp Çɥʇ uá´‰ Çɯᴉʇ ÉŸo uoá´‰sᴉʌᴉpqns ʇsÇllÉɯs Çɥ┴

    That spoiled it! πŸ˜‰

  • Adding a binary value to datetime is not the same as adding an integer value. - this I know.
    Adding 32 to datetime adds 32 days
    Adding x20 to datetime adds 107 milliseconds
    WHY - THAT I DON'T KNOW, YET!!

  • Because it isn't adding 32 to the date time value:

    NewDate                 DateAsBinary                                                       NewDateAsBinary
    ----------------------- ------------------------------------------------------------------ ------------------------------------------------------------------
    2001-01-01 00:00:00.107 0x0000901A00000000                                                 0x0000901A00000020

  • That I can understand.  However πŸ™‚
    Where is the logic in doing a calculation in a different datatype than what the result will be displayed as?

  • OH and BTW thank you for your answer.

  • I enjoy date math.  Thomas explained the answer above.

    If you add an integer to a datetime data type, it adds that number of days and returns the correct datetime.  This meets the standard of date + interval = new date.

    Not so with datetime2.  It gives an operand type clash error.
    The one that really gets me is the date data type.  It gives the same error.

    Microsoft did a lot of things right with the datetime type, but missed the boat with the newer ones.  I don't know why they made the decisions they did.
    DATEADD works with both, but not straight addition and subtraction.

  • Budd - Tuesday, November 7, 2017 12:00 PM

    That I can understand.  However πŸ™‚
    Where is the logic in doing a calculation in a different datatype than what the result will be displayed as?

    In this particular case (binary level), probably nothing other than finding out if you actually know how the DATETIME datatype works.  In real life, I use direct date math a lot (but not at the binary level).

    --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 11 posts - 1 through 10 (of 10 total)

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