Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Datediff question Expand / Collapse
Author
Message
Posted Thursday, November 22, 2007 9:56 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, June 08, 2011 4:12 PM
Points: 146, Visits: 120
Comments posted to this topic are about the item

Because time is not infinite ... above all in milliseconds :D

How to do?
Post #425128
Posted Monday, November 26, 2007 5:00 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Monday, October 20, 2008 4:01 PM
Points: 147, Visits: 53
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!)
Post #425671
Posted Monday, November 26, 2007 5:17 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, June 08, 2011 4:12 PM
Points: 146, Visits: 120

declare @timems numeric
select @timems =(cast(datediff (dd,getdate()-28,getdate()) as numeric)* 86400000)
select @timems
--86400000 msxday
Post #425677
Posted Monday, November 26, 2007 12:54 PM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Thursday, April 10, 2014 3:50 PM
Points: 872, Visits: 952
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
Post #425961
Posted Tuesday, November 27, 2007 12:04 PM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Saturday, June 29, 2013 7:54 AM
Points: 438, Visits: 920
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.



Post #426548
Posted Tuesday, November 27, 2007 2:24 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, June 08, 2011 4:12 PM
Points: 146, Visits: 120
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 :P
Post #426595
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse