Just the time, please

  • Steve Jones - SSC Editor

    SSC Guru

    Points: 715912

    Comments posted to this topic are about the item Just the time, please

  • George Vobr

    SSCrazy Eights

    Points: 8980

    Thanks for this question Steve. I repeated the conversion time to datetime2...:ermm:
    For the result to 1900-01-01 10:00:00.000 should be in the code specified DECLARE @t DATETIME2(3) = '10:00 am';
    Without running the code in SSMS can be found the right answer in the Dosc MS time (Transact-SQL), or maybe even better in TECHNET Using Date and Time Data

  • Luis Cazares

    SSC Guru

    Points: 183569

    George Vobr - Tuesday, April 4, 2017 9:18 AM

    Thanks for this question Steve. I repeated the conversion time to datetime2...:ermm:
    For the result to 1900-01-01 10:00:00.000 should be in the code specified DECLARE @t DATETIME2(3) = '10:00 am';
    Without running the code in SSMS can be found the right answer in the Dosc MS time (Transact-SQL), or maybe even better in TECHNET Using Date and Time Data

    The value is the same.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • Revenant

    SSC-Forever

    Points: 42467

    Really, really trivial. Thanks, Steve!

  • Jeff Moden

    SSC Guru

    Points: 994683

    Actually (and without giving up the correct answer here), none of the answers are correct because the correct answer doesn't have enough zeroes to the right of the decimal point. ๐Ÿ˜‰

    --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.
    "If you think its expensive to hire a professional to do the job, wait until you hire an amateur."--Red Adair
    "Change is inevitable... change for the better is not."
    When you put the right degree of spin on it, the number 3|8 is also a glyph that describes the nature of a DBAs job. ๐Ÿ˜‰

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

  • Stewart "Arturius" Campbell

    SSC Guru

    Points: 71401

    Nice, easy one, thanks Steve...

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

  • George Vobr

    SSCrazy Eights

    Points: 8980

    Luis Cazares - Tuesday, April 4, 2017 9:36 AM

    George Vobr - Tuesday, April 4, 2017 9:18 AM

    Thanks for this question Steve. I repeated the conversion time to datetime2...:ermm:
    For the result to 1900-01-01 10:00:00.000 should be in the code specified DECLARE @t DATETIME2(3) = '10:00 am';
    Without running the code in SSMS can be found the right answer in the Dosc MS time (Transact-SQL), or maybe even better in TECHNET Using Date and Time Data

    The value is the same.

    Hi Luis,
    it's not about value, but display the result. Indeed, the Column length (bytes) of the variable @t with a precision of 7 is different than with precision 3.

  • Steve Jones - SSC Editor

    SSC Guru

    Points: 715912

    I changed the DECLARE. You're right, the precision is different with the default (7)

Viewing 8 posts - 1 through 8 (of 8 total)

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