This question already has answers here:
How do I convert a comma-separated string into an array?
(4 answers)
Closed 3 years ago.
Front End Request
?date_filter=2019-03-12,2019-03-13
As you see, I am passing two dates in request from front end to ruby controller.
I want to convert those dates into below format so that I can use them in my SQL query
Expected Result:
['2019-03-12', '2019-03-13']
First get the query string data, then do the split on it, it will result an array of the values.
dates = request.query_parameters['date_filter']
result = dates.split(',')
result would be ['2019-03-12', '2019-03-13']
Let a be the query parameter you get the to get the required result use
a = "2019-03-12,2019-03-13"
a.split(",") //gives ["2019-03-12", "2019-03-12"]
Related
This question already has answers here:
Substitute first X occurrences
(2 answers)
RegexReplace the nth occurrence of a string of underscores
(1 answer)
Reference - What does this regex mean?
(1 answer)
Closed 4 months ago.
I am wondering in google sheets if it is possible to replace the second character.
ex. abc123/def123/ghi123
I want to replace the second slash after def123 to a colon. So I want it shown as abc123/def123:ghi123
Thanks!
This question already has an answer here:
How to index match an array of cells to see if each one will match? [duplicate]
(1 answer)
Closed 2 years ago.
I want to partial match the following range of strings:
against this range of strings:
and if there is a match, output the original values from the original range:
I've tried nested IFS and VLOOKUPS, which strangely didn't work for me:
=IF(VLOOKUP(""&$B$1&"",E1,1,FALSE)=E1,$B$1,IF(VLOOKUP(""$B$2&"",E1,1,FALSE)=E1,$B$1)
I've also tried:
=SUMPRODUCT(--ISNUMBER(SEARCH(B1:B22,E1)))
Which got close, but it produced only digits for me in the end, when I want the original string from the 1st range I'm using.
I only want to use formulas, not script.
Using your SUMPRODUCT construction and adding "*" before and after the search string and using it inside an index function:
=IFERROR(INDEX($B$1:$B$22,IF(--ISNUMBER(SEARCH("*"&$B$1:$B$22&"*",$E$1:$E$25))=1,ROW($B$1:$B$22),"")),"")
You can use below formula and see if it helps your situation.
=LOOKUP(2^15,SEARCH($B$1:$B$22,E1,1),$B$1:$B$22)
Here 2^15 is a number larger than maximum number of characters that Excel cell can hold.
Note: I am sure about this formula in Excel. However, I have not tested this formula in google-sheets.
This question already has an answer here:
PostgreSQL jsonb value in WHERE BETWEEN clause
(1 answer)
Closed 3 years ago.
I'm working with Rails 5 + Postgres.
I have a Postgres JSONB column named data with data that looks something like:
{username: 'McGruff', timestamp: 123456789}
I would like to query for data that is between two timestamps, to get a subset of records that all have a timestamp within some range (say, the last 24 hours).
Using comments from below, the answer is:
Model.where("(data->'timestamp')::int BETWEEN ? AND ?", start, end)
Thanks for the help!
Use where clause by providing start & end inputs as strings. as the data stored in string format in jsonb column.
somewhat like below:
Model.where((data->>'timestamp')::int between ? and ?, start, end)
This question already has answers here:
Handling unix timestamp with highcharts
(2 answers)
Closed 4 years ago.
I am working with HighCharts and I try to pass values, but I don't get the expected results. My idea is to pass two values the first is Date and the second the value for that date.
1. I am using the Highstock model.
2. I try to create an array of arrays, where each element has two values [a,b] or in my case a is a Date and b is the value that I want on the chart. The function that creates the first array looks like this:
var results = [];
for (x = 0; x < data.total_rows; x++) {
var aValueTmp = parseInt(data.rows[x].key)*1000;
var aValue = new Date(timeStampTmp);//not needed
var bValueTmp = data.rows[x].value;
var bValue = parseInt(valTmp);
results.push([aValueTemp, bValue]);
}
createChart(results);
So this part works. createChart is another function where I create the HighChart. The part where I pass the data looks like this:
series:[{
name: 'Measurements',
data: results
}],
Problem:
1. So aValueTemp gets the date in Epoch format, and then aValue calculates it in Unix format. When I pass the data as shown in the code above, then it looks like all the values are from 1 of January.
2. When I switch in my function and pass the aValueTemp instead of aValue then it is not drawing a line in the chart. But now the date is different 18.January, which again it is not the value I am passing.
Can someone help me?
It was a duplicate. The solution is to multiply the aValueTemp by 1000 so that I get values in ms.
This question already has answers here:
Find the first empty cell in the same column/row
(3 answers)
Closed 5 years ago.
I'm trying to get the first cell that is empty in a column but I don't have an idea how to accomplish that.
For example, I have this column
How can i get for example in A:7 that the first empty cell is 5 (i only get the number)
I tryied this, but is giving me a error
In A7 enter the array formula:
=MIN(IF(A1:A6="",ROW(A1:A6)))
Array formulas must be entered with Ctrl + Shift + Enter rather than just the Enter key.
EDIT#1:
Here is the Google Sheet equivalent: