Just the time, please

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

  • 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

  • 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
  • Really, really trivial. Thanks, Steve!

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

    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)

  • Nice, easy one, thanks Steve...

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

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

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

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

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