interval

How to convert an interval like "1 day 01:30:00" into "25:30:00"?

I need to add some intervals and use the result in Excel. Since sum(time.endtime-time.starttime) returns the interval as "1 day 01:30:00" and this format breaks my Excel sheet, I thought it'd be nice to have the output like "25:30:00" but found no way to do it in the PostgreSQL documentation. Can anyone here help me out? ...

How can I group by specific timestamp intervals in C# using LINQ?

I have a list with tick objects including a pair of a double value and a timestamp. I want to separate the list into child-lists depending on a time interval (for example 15 minutes). One list only has the tick objects from: 8:00:00 - 8:14-59 usw usw C#-code: var result = from tick in listTicks group tick by tick.timestamp.Hour; Th...

Rounding a Java BigDecimal to the nearest interval

I have a BigDecimal calculation result which I need to round to the nearest specified interval (in this case it's the financial market tick size). e.g. Price [Tick Size] -> Rounded Price 100.1 [0.25] -> 100 100.2 [0.25] -> 100.25 100.1 [0.125] -> 100.125 100.2 [0.125] -> 100.25 Thanks. Update: schnaader's solution, translated into J...

Is there an easy way to Calculate and format time/date intervals in java?

I'm familiar with the the date and time classes in the JDK and their associated formatting methods. I may be blind, but I cannot find an equivalent set of classes for processing time intervals. For example, I would like to display the number of days for a given long value of milliseconds. I realize that the method to do these conversions...

Does an open-ended interval implementation exist for Java?

I've got a classification of certain values in different intervals. Most have the form [20-30], but some are of the form [30-infinite). Is the an interval class you know of which can represent: an interval which is not closed on both sides (e.g. (0-5) or [0-5) ) an interval which closes (or starts) on infinite ...

Getting number of certain days-of-the-week (weekend) from interval in PostgreSQL.

Given 2 timestamps in postgres, how do you calculate the time difference without counting whole Saturdays and Sundays? OR How do you count the number of Saturdays and Sundays in a given time interval? ...

Selecting date intervals, doing it fast, and always returning the latest entry with the result.

I have a database with a table, storing changes in account-balance across a couple of accounts, with three columns; float balance, #The account balance after the change Date date, #Date that balance change occurred int aid #Account that the balance change occurred on It contains a couple of entries for each day of the...

How do I convert an interval into a number of hours with postgres?

Say I have an interval like 4 days 10:00:00 in postgres. How do I convert that to a number of hours (106 in this case?) Is there a function or should I bite the bullet and do something like extract(days, my_interval) * 24 + extract(hours, my_interval) ...

Get a Unix script to run at exactly the same time every time

I am writing a script to capture disk usage on a system (yes, I know there is software that can do this). For database reporting purposes, I want the interval between data points to be as equal as possible. For example, if I am polling disk usage every 10 minutes, I want every data point to be YYYY-MM-DD HH:[0-5]0:00. If I'm am pollin...

How to smoothly animate Windows Forms location with different speeds?

I've been trying to smoothly animate some Windows Form location but I'm having some issues if I want the speed to be variable. In other words, if I want to allow the user to select the preferred speed for animation. I've found the following article that helped me quite a bit to perform the animation I was looking for, for my form. It se...

format interval with to_char

Following SQL command select TO_CHAR(NVL(arg1 - arg2, TO_DSINTERVAL('0 00:00:00'))) from table1 produces a result of the format: +000000000 00:03:01.954000. Is it possible to enter a special format in the to_char function in order to get a result of format: +00 00:00:00.000? ...

How to tail -f a file (or similar) for a specified interval?

I am working on adding some nagios alerts to our system -- some of which will monitoring the rate of certain events hitting the nginx/apache logs (or parsing values from those logs.) The way I've approached the problem so far is with a simple shell script tail -f'ing the log for 25 seconds or so to a temporary file, killing the process, ...

Union of intervals

I've got a class representing an interval. This class has two properties "start" and "end" of a comparable type. Now I'm searching for an efficient algorithm to take the union of a set of such intervals. Thanks in advance. ...

Using Hibernate HQL to select records where two dates are within a specified interval

I'm trying to use HQL to find records where two date fields are within 1 month of each other. Query query = session.createQuery("from com.ep.cqprojects.db.Projects " + "where active_date - kickoff_meeting_date < interval '1' month "); Unfortunately the database used apparently doesn't understand interval. How can I compare the in...

Python: Mapping from intervals to values

Hi, I'm refactoring a function that, given a series of endpoints that implicitly define intervals, checks if a number is included in the interval, and then return a corresponding (not related in any computable way). The code that is now handling the work is: if p <= 100: return 0 elif p > 100 and p <= 300: return 1 elif p > 300 ...

intersect time intervals and generating new ones depending on intersect-results

hi there, i've got two tables with time intervals and some settings for each interval, eg 2009-01-01T06:00:00 2009-01-04T14:00:00 1 0 2009-01-04T22:00:00 2009-01-07T06:00:00 2 1 2009-01-07T06:00:00 2009-01-09T13:00:00 2 2 2009-01-09T22:00:00 2009-01-14T06:00:00 3 0 and 2009-01-04T16:00:00 2009-01-05T01:00:00 2 0 2009...

How does one break out of a Set Interval in Action Script 2

p2 = setInterval(function () { clearInterval(p2); some code here; }, waitTime) I need to break out of this interval in a separate function. This plays an array of SWF movies - there is a purge function that needs to stop this interval. How can I stop this interval from a separate function in AS2? ...

MySQL - return only entries from the past X days

I'm working with a database that has date information stored as a Unix timestamp ( int(11) ) and what I want to do is only return entries from the past X days, the past 90 days for example. What I've come up with is: SELECT * FROM mytable WHERE category=1 AND FROM_UNIXTIME( time ) > DATE_SUB(now(), INTERVAL 91 DAY) Where 'time' is t...

python time interval algorithm sum

Hello Assume I have 2 time intervals,such as 16:30 - 20:00 AND 15:00 - 19:00, I need to find the total time between these two intervals so the result is 5 hours (I add both intervals and subtract the intersecting interval), how can I write a generic function which also deals with all cases such as one interval inside other(so the result ...

C Programming How to find the time interval between events

Im using a handyboard and interactive c software and the task is to find the rpm of a lego motor in real time using an Infrared "Break Beam" Sensor on the wheel. I was thinking about finding the time interval between the beam being broken and then from there calculating the rpm but i cant figure out exactly how to do that. Any help would...