473,396 Members | 1,927 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Calculating amount of time that falls into a specific range

Hello

Can someone help me with this one please! Im working on a service level tracking database which records the times that a service goes down during the day (DowntimeStart/DowntimeEnd) and compares this to the times that it is required to be available (SLAStart/SLAEnd). I want to return the amount of time the service was down during the SLA period in minutes.
Expand|Select|Wrap|Line Numbers
  1. Date,    DowntimeStart,  DowntimeEnd, SLAStart, SLAEnd
  2. 1/1/08,     15:00,          23:00,      18:00,   20:00.
  3. 2/1/08,     15:00,          16:00,      15:30,   20:00.
The result for record 1 above should be 120 minutes.
The result for record 2 above should be 30 minutes.

Hope you can help....

Regards

Gary
Dec 21 '08 #1
9 1649
ADezii
8,834 Expert 8TB
@garyb2008
Gary, please clarify something for me before we proceed. In Record #1, the Down Time Start (DowntimeStart) was 3 hours prior to the Available Time Start (SLAStart), namely 15:00 ==> 18:00. The Down Time End (DowntimeEnd) also extended 3 hours passed the allowable Available Time End (SLAEnd), namely 23:00 ==> 20:00. Should not the result for Record 1 be 360 minutes?
Dec 21 '08 #2
NeoPa
32,556 Expert Mod 16PB
Gary, a query with the following SQL embedded in it should help :
Expand|Select|Wrap|Line Numbers
  1. SELECT [Date],
  2.        IIf([DowntimeEnd]<[SLAEnd],[DowntimeEnd],[SLAEnd])-
  3.        IIf([DowntimeStart]>[SLAStart],[DowntimeStart],[SLAStart]) AS SLADownTime
  4. FROM ...
I have no table information supplied so you'll have to fill that info in for yourself ;)
Dec 21 '08 #3
NeoPa
32,556 Expert Mod 16PB
@ADezii
Downtime Start / End specifies the time the system was actually down.
SLA Start / End specifies the time we actually care about the system being down.

Although the system was down for 8 hours (480 mins = 23:00 - 15:00), we only care that it was down all the time (2 hours) between 18:00 to 20:00 (120 mins).
Dec 21 '08 #4
ADezii
8,834 Expert 8TB
@NeoPa
Gotcha! Thanks for the explanation.
Dec 22 '08 #5
NeoPa
32,556 Expert Mod 16PB
No worries :)

It's rare enough that I even understand what an OP is asking for, so it's worth posting when I do ;)
Dec 22 '08 #6
ADezii
8,834 Expert 8TB
Here is a rather weird solution that I came up with, probably not even Post-Worthy, but I'll throw it up here anyway, just in case no other alternative works! (LOL).
Dec 22 '08 #7
Hi Guys

Thanks for looking into this while i was away, was havin a time out from the project over christmas. I think ill go with NeoPa's solution for this, but im keeping your function ADezii's as with a few modifications it may solve another requirement i know will also be needed.

Happy new year all

Gary

Regards

Gary
Dec 30 '08 #8
ADezii
8,834 Expert 8TB
@garyb2008
Same here Gary, from all of us at Bytes!
Dec 30 '08 #9
NeoPa
32,556 Expert Mod 16PB
I think a lot of us had a time-out over Christnmas Gary :)

I'm glad this is clearer now. Have a very Happy New Year :)
Jan 5 '09 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: querypk | last post by:
X-No-Archive: yes Can some one help me improve this block of code...this jus converts the list of data into tokens based on the range it falls into...but it takes a long time.Can someone tell me...
2
by: androtech | last post by:
Hello, I'm looking for a function that returns a date range for a specified week number of the year. I'm not able to find functions like this anywhere. Any pointers/help would be much...
3
by: Miller | last post by:
Hi, Can someone tell me how to calculate MFLOPS for the following C# code (on a Pentium 4 2.0 Ghz)? for (i=0; i<n; i++) { for (j=0; j<n; j++) { for (k=0; k<n; k++)
38
by: jdcrief | last post by:
Complier: Visual C++ 2005 Express Edition The program I wrote will compile and execute, but the output is always the same, no matter what number is entered in for the radius of the circle. ...
22
by: dos.fishing | last post by:
Hello, I'm writing a function that should do the following: /** * Calculate and return fraction of valueA where max fractions is 31. * param valueA A five bit value, 0-31. * param valueB The...
5
by: simchajoy2000 | last post by:
Hi, I need to calculate a range of colors given the beginning and ending colors in hex values (i.e. blue to red). I know there is a logic to hex numbers and there is probably a fairly simple...
25
by: Umesh | last post by:
i want to calculate the time required to execute a program. Also i want to calcute the time remaining for the execution of the program. how can i do that? pl mention some good websites for...
6
by: Rickster66 | last post by:
I have a database where order numbers are entered by a group of 25 users. The Access database is split. As each order number is entered, a time stamp using a general format is used on the table. Now,...
3
rcollins
by: rcollins | last post by:
I ahve a database that I put together to keep track of the office supplies. We input what has been purchased and what goes out. When I run a report, usually it is just for a month, but I have a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.