Date Time range

  • Comments posted to this topic are about the item Date Time range

  • This was removed by the editor as SPAM

  • Thanks Daniel - nice question.

  • nice question. thanks

  • Good questions, thanks.

    Unfortunately, I rushed the answer and got it wrong! Doh!

    Not enough due diligence 🙂

    _____________________________________________________________________
    [font="Comic Sans MS"]"The difficult tasks we do immediately, the impossible takes a little longer"[/font]

  • I had to figure out why I wasn't getting the right answer in my head.

    I would look at the select statement and think Ben and David was the answer. I had excluded the other two because the times were equal to the begin and end expressions after rounding. Well, This is why I was getting a different answer.

    When using BETWEEN-

    "BETWEEN returns TRUE if the value of test_expression is greater than or equal to the value of begin_expression and less than or equal to the value of end_expression."

    note: begin_expression >= test_expression <= end_expression

    When using NOT BETWEEN-

    "NOT BETWEEN returns TRUE if the value of test_expression is less than the value of begin_expression or greater than the value of end_expression."

    note: begin_expression > test_expression < end_expressions

    reference: msdn

    Thanks for the question

    ______________________________________________________________________________________________
    Forum posting etiquette.[/url] Get your answers faster.

  • Nice question, thanks.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • Interesting question. I knew about the rounding thing which helped. I did try to run the code but it failed due to me having a UK setup (as the question hinted).

  • Good question. If there was a time with 29.999 seconds as the last bit it would have gotten me.

  • Good question. I looked at it quickly and would have answered wrong and I hadn't double checked and caught the smalldatetime.

    http://brittcluff.blogspot.com/

  • Nice Question.

    I always wondered what they thinking when this was done.

    Why would you want to make an existing data type that has been accurate to the second for almost twenty years and change it to round to the minute?

    I guess someone wanted to re-write ALOT of code.

  • SanDroid (6/22/2011)


    Why would you want to make an existing data type that has been accurate to the second for almost twenty years and change it to round to the minute?

    Space. If being accurate to the second doesn't matter then why store the extra bits? The last application I worked on had a number of date columns that didn't need seconds stored but still did. Combine that with a number of other wasteful practices and I'm sure that, with a ton of recoding and effort, a lot of space could have been freed up which would also result in a performance gain, both when using and for maintenance.

  • cfradenburg (6/22/2011)


    SanDroid (6/22/2011)


    Why would you want to make an existing data type that has been accurate to the second for almost twenty years and change it to round to the minute?

    Space. If being accurate to the second doesn't matter then why store the extra bits? The last application I worked on had a number of date columns that didn't need seconds stored but still did. Combine that with a number of other wasteful practices and I'm sure that, with a ton of recoding and effort, a lot of space could have been freed up which would also result in a performance gain, both when using and for maintenance.

    That first if is the point. This causes more space to be used not less.

    Now to be accurate to the second a larger data type has to be used.

    Not good to change an existing Data Type to be less accurate and force everyone to use more space.

  • According to BOL datetime uses 8 bytes and smalldatetime uses 4 bytes.

  • Thanks Daniel

    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 - 1 through 15 (of 19 total)

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