Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
|
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 29th, 2003, 05:41 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default Missing time part while calculating the Delay

Hi All there,

I am checking the average/max/min delay of the messages sent. When I do this, I do miss out the milliseconds part.

I use Datediff() with seconds as the unit to find the same.

Eg: If the exact delay is 8 seconds and 678 milliseconds, I do miss out 678 milliseconds. If I go for "ms" with the datediff(), then I have to calculate it for seconds too. If the delay is in minutes, then I get a data overflow error, for the "ms" with datediff().

Is there any other way to get the exact delay?

regards,

-Vijay G
__________________
- Vijay G
 
Old October 29th, 2003, 07:47 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 839
Thanks: 0
Thanked 1 Time in 1 Post
Default

DATEDIFF() returns the difference between two datetime values as measured by the number of the indicated intervals crossed. The result is an integer number of intervals.

If you use an interval value of 's' (seconds), then the function calculates the number of second intervals crossed between the two datetime values. Using 'ms' calclates the number of millisecond boundaries crossed, etc.

Thus, the result is an integer number of boundaries crossed. In other words, it calculates the difference for a single interval type only, and it is not possible to combine multiple types in the same operation. You'll have to convert the single interval type result yourself into multiple types.

If you use milliseconds, then integer dividing by 1000 converts to seconds, etc.

Since the result is an integer, using milliseconds allows you to express an interval of a bit less than 25 days before you get an overflow. If your total interval is more than that, you'd have to do some tricky manipulations involving normalizing the endpoints to two consecutive days and then adding in the whole number of days in milliseconds between the actual dates.

Not something I'd wnat to do in SQL...

Jeff Mason
Custom Apps, Inc.
www.custom-apps.com
 
Old October 29th, 2003, 11:57 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Yes Jeff,

You are right. I have no other option. Should calculate it all from the frontend. I thought I would do it all from sql, and ask my support team to just use the query. But since these calculations are involved, I should give them a UI presenting the calculated data.

Thanks for you suggestions.

Cheers,

-Vijay G





Similar Threads
Thread Thread Starter Forum Replies Last Post
Time delay in BizTalk - Verastream Interface benvictor Biztalk 0 July 15th, 2008 04:20 PM
Crystal Reports missing part of data JMCHAP1 Crystal Reports 1 August 7th, 2006 09:41 AM
How i can insert specific delay time in microsseco eakkaluck Visual C++ 1 November 2nd, 2005 05:52 PM
time delay pab006 Classic ASP Basics 2 January 29th, 2004 05:16 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.