Questions tagged [intervals]

Intervals are used to measure “distance” between values.

Intervals are used to measure “distance” between values.

In the DBMS world interval typically refers to the period between 2 timestamps, many modern RDBMS systems natively supports intervals and operation with them.

More information on the intervals can be found in the wild.

2903 questions
14
votes
3 answers

MySQL INTERVAL Mins

I am trying to get the all records which are 2 hours or more old using this query: $minutes = 60 * 2 SELECT COUNT(id) AS TOTAL, job_id from tlb_stats WHERE log_time >= DATE_SUB(CURRENT_DATE, INTERVAL $minutes MINUTE) GROUP BY job_id It only…
Maximus
  • 2,906
  • 4
  • 35
  • 55
14
votes
1 answer

How to stop $interval on leaving ui-state?

Angular, UI-router. Using $interval in a controller of a state like so: $scope.Timer = null; $scope.startTimer = function () { $scope.Timer = $interval($scope.Foo, 30000); }; $scope.stopTimer = function () { if…
VSO
  • 11,546
  • 25
  • 99
  • 187
13
votes
2 answers

More than 24 hours in a day in postgreSQL

Assuming I have this schema: create table rental ( id integer, rental_date timestamp, customer_id smallint, return_date timestamp, ); Running this query returns strange results: select customer_id, avg(return_date -…
rap-2-h
  • 30,204
  • 37
  • 167
  • 263
13
votes
5 answers

Data structure for handling intervals

I have got a series of time intervals (t_start,t_end), that cannot overlap, i.e.: t_end(i) > t_start(i+1). I want to do the following operations: 1) Add new (Union of) intervals [ {(1,4),(8,10)} U (3,7) = {(1,7),(8,10)} ] 2) Take intervals out […
Luís Guilherme
  • 2,620
  • 6
  • 26
  • 41
12
votes
9 answers

Joda Time LocalTime of 24:00 end-of-day

We're creating a scheduling application and we need to represent someone's available schedule during the day, regardless of what time zone they are in. Taking a cue from Joda Time's Interval, which represents an interval in absolute time between two…
Garret Wilson
  • 18,219
  • 30
  • 144
  • 272
12
votes
1 answer

Actual frequency of device motion updates lower than expected, but scales up with setting

I am porting an app that I originally wrote using the accelerometer for IOS 3, to incorporate the new IOS 4 motion capabilities. While capturing motion, the application does little else - no graphics updates for example. I'm doing the following to…
J.Spiral
  • 475
  • 5
  • 10
12
votes
7 answers

Find which interval row in a data frame that each element of a vector belongs in

I have a vector of numeric elements, and a dataframe with two columns that define the start and end points of intervals. Each row in the dataframe is one interval. I want to find out which interval each element in the vector belongs to. Here's some…
Ben
  • 41,615
  • 18
  • 132
  • 227
12
votes
1 answer

Finding "maximum" overlapping interval pair in O(nlog(n))

Problem Statement Input set of n intervals; {[s_1,t_1], [s_2,t_2], ... ,[s_n,t_n]}. Output pair of intervals; {[s_i,t_i],[s_j,t_j]}, with the maximum overlap among all the interval pairs. Example input intervals : {[1, 10], [2, 6], [3,15], [5,…
user1751434
  • 135
  • 1
  • 1
  • 5
12
votes
2 answers

Is it okay to use Thread.sleep() in a loop in Java, to do something at regular intervals?

I have read some threads that said that calling Thread.sleep() in a loop is problematic and is a serious performance issue. But in some cases it seems the most natural thing to do. For example if I want my application to do something every 3 minutes…
Alexandru Chirila
  • 2,274
  • 5
  • 29
  • 40
12
votes
1 answer

Increment Range using Fenwick Tree

I was wondering if a Fenwick Tree (or Binary Indexed Tree) can be modified to: 1) Increment the frequency all elements in a range by a certain amount 2) Query the frequency of a single element. This is as opposed to the traditional Fenwick Tree…
Peter
  • 415
  • 7
  • 13
11
votes
2 answers

Interval inside React useEffect - store it in a useRef Hook to preserve value overtime warning

So I have this method: useEffect(() => { //.. other logic here // Firefox doesn't support looping video, so we emulate it this way video.addEventListener( "ended", function() { video.play(); }, false …
I am L
  • 4,288
  • 6
  • 32
  • 49
11
votes
2 answers

Plotting a 95% confidence interval for a lm object

How can I calculate and plot a confidence interval for my regression in r? So far I have two numerical vectors of equal length (x,y) and a regression object(lm.out). I have made a scatterplot of y given x and added the regression line to this plot.…
Max Lester
  • 133
  • 1
  • 1
  • 8
11
votes
3 answers

Haskell Range Map library

Is there a Haskell library that allows me to have a Map from ranges to values? (Preferable somewhat efficient.) let myRangeMap = RangeMap [(range 1 3, "foo"),(range 2 7, "bar"),(range 9 12, "baz")] in rangeValues 2 ==> ["foo","bar"]
mrueg
  • 8,185
  • 4
  • 44
  • 66
11
votes
1 answer

pause a angular interval and then resume

I have a function that i repeat every 10 second. This works fine. It shows orders. Now i want a accept order function. But when this is clicked i want to pauze the interval. And when accept order returns i want to resume this interval again. what is…
Reza
  • 880
  • 1
  • 10
  • 29
11
votes
3 answers

SQL statement that calculates per-interval growth

In our database we do have a table that keeps track of the power consumption of a device. The rate at which new values get inserted is not fixed, they only get written when there really is a change, so the temporal distance between the values is…
Rob
  • 11,492
  • 14
  • 59
  • 94