2,963 questions
260
votes
9
answers
331k
views
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(...
243
votes
4
answers
570k
views
Postgresql query between date ranges
I am trying to query my postgresql db to return results where a date is in certain month and year. In other words I would like all the values for a month-year.
The only way i've been able to do it ...
132
votes
9
answers
117k
views
Do something every x minutes in Swift
How can I run a function every minute?
In JavaScript I can do something like setInterval, does something similar exist in Swift?
Wanted output:
Hello World once a minute...
92
votes
5
answers
69k
views
Using a variable period in an interval in Postgres
I have a relation that maintains monthly historical data. This data is added to the table on the last day of each month. A service I am writing can then be called specifying a month and a number of ...
79
votes
10
answers
19k
views
How to join two dataframes for which column values are within a certain range?
Given two dataframes df_1 and df_2, how to join them such that datetime column df_1 is in between start and end in dataframe df_2:
print df_1
timestamp A B
0 2016-05-14 10:...
60
votes
7
answers
128k
views
How can I use ranges in a switch case statement using JavaScript?
How can I use ranges in a switch case statement using JavaScript? So, instead of writing code for each and every single possibility, I'd like to group them in ranges, For example:
switch(myInterval){
...
60
votes
3
answers
228k
views
How do you create vectors with specific intervals in R?
I have a question about creating vectors. If I do a <- 1:10, "a" has the values 1,2,3,4,5,6,7,8,9,10.
My question is how do you create a vector with specific intervals between its elements. For ...
58
votes
11
answers
80k
views
Show TimePicker with minutes intervals in android
My application show a TimePickerDialog to set a time.
I want that the timePickerDialog show the minutes with an interval of 5 minutes.
This works fine with this code:
private final int ...
52
votes
3
answers
232k
views
Working with INTERVAL and CURDATE in MySQL
I'm building a chart and I want to receive data for each month.
Here's my first request which is working:
SELECT s.GSP_nom AS nom, timestamp, AVG( v.vote + v.prix ) /2 AS avg
FROM votes_serveur ...
49
votes
15
answers
54k
views
How to wrap a float to the interval [-pi, pi)
I'm looking for some nice C code that will accomplish effectively:
while (deltaPhase >= M_PI) deltaPhase -= M_TWOPI;
while (deltaPhase < -M_PI) deltaPhase += M_TWOPI;
What are my options?
48
votes
4
answers
32k
views
Run a function periodically in Scala
I want to call an arbitrary function every n seconds. Basically I want something identical to SetInterval from Javascript. How can I achieve this in Scala?
47
votes
8
answers
212k
views
How can I determine if a variable has a value that is between two distinct constant values?
How can I determine using PHP code that, for example, I have a variable that has a value
between 1 and 10, or
between 20 and 40?
47
votes
3
answers
52k
views
how to convert integer minutes to interval in postgres
I'm trying to convert minutes which are in integer to interval in postgres
Is there any function that will help me to convert it to interval or should i have divide it by 60 and get the final result
...
46
votes
4
answers
296k
views
How can I plot data with confidence intervals?
If I have 10 values, each of which has a fitted value F, and an upper and lower confidence interval U and L:
set.seed(0815)
F <- runif(10, 1, 2)
L <- runif(10, 0, 1)
U <- runif(10, 2, 3)
...
46
votes
1
answer
36k
views
Make a range in postgres
How can I make a range in a select in PostgreSQL? I'd like to have this result:
num
---
1
2
3
4
5
6
From a query like:
SELECT range(1,6) AS num;