Datediff question

  • Comments posted to this topic are about the item

    Because time is not infinite ... above all in milliseconds 😀

    How to do?

  • The explanation is a little lacking. The cause of the overflow error is the use of ms (millisecond)in the command. If another unit of time is used ie second, then no error will result. BOL actually state the maximum length of time. I will leave it to the reader to find this number. (Boy did I hate this statement at uni when I was studying mathematics!)

  • declare @timems numeric

    select @timems =(cast(datediff (dd,getdate()-28,getdate()) as numeric)* 86400000)

    select @timems

    --86400000 msxday

  • The following will work even for the ms (milli second) unit of time:

    select datediff (ms,getdate()-24,getdate())

    Explanation can be found at:

    http://technet.microsoft.com/en-us/library/ms189794.aspx

  • Nothing worth "bragging" about. All I had to do was run that query in the Query Analyzer.

    And got the answer instantanewously, no delay at all.

    So, such trick questions buying "braging" rigths are just too easy.

    :doze:

  • Practically all the questions are answered using a query analyzer and/or a google search, but this isn't the way to answer them ... we aren't at school 😛

  • Thanks for the question.

  • I agree with the other posts. The problem is the ms and this isn't really discussed in the answer.

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

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