In my database I have two columns. First is called starting and the other isending. Both are formatted like 11:00. How to get the interval between ending and starting.
I have tried whereBetween, but it didn't work as I think.
You can use Carbon to get the difference, it offers a number of functions for calculating time differences. For example:
$end->diffInSeconds($start);
$end->diffInHours($start);
$end->diffInDays($start);
Those are just a few, see the docs for more examples
you have two methods first you can use double where like
$blablabla= Category::
where('starting','<=','your variable here')
->where('ending','>=','your variable here')
->first();
second method
whereRaw with bindings, where you use the raw condition and a binding for the variable:
whereRaw('? between starting and ending', [$yourVariable])
BOUNCE
wherebetween is for check the column value between two given values (intervals)
not the opposite you wanna check given value between two columns
Related
I am using jmeter to test ldap.
As part of my test, I want to search for a random uid on each iteration. I did not find a straight forward answer to this. So my idea was to first select a random number 1-200 and saving that number as a variable named uid, that number would correspond to a UDV name.
For example
uid = 2 and 2 = A123456
in my udv list. However when trying to reference this variable in my ldap search filter.I am trying to use
(uid=${${uid}})
in hopes to get the value of the value of uid. However the search results just show this as a string.
<searchfilter>(uid=${${uid}})</searchfilter>
Is there another way to achieve what I am looking for?
Use __V function
${__V(${uid})}
The V (variable) function returns the result of evaluating a variable name expression. This can be used to evaluate nested variable references
${__V(A${N})} - works OK. A${N} becomes A1, and the __V function returns the value of A1
Perhaps the easiest would be going for __RandomFromMultipleVars() function?
Another option is using __V() function, it can combine and evaluate JMeter Variables
I'm trying to find a way to see if I can find a way to determine if a time that I stipulate falls between two other times. For example:
Start End
11:33:48 11:53:48
12:20:22 12:38:21
12:39:27 13:00:09
14:16:23 14:20:49
14:20:54 14:22:56
Then, I want to check if a cell (here the value of 12:50 in cell E30) falls between ANY two values in a range in THE SAME ROW. For me, I can get the obvious way to check for this in one row, and this simple version totally works:
=If(AND(E30>A4,E30<B4), "TRUE", "FALSE")
However, I want to check if that number falls within ANY of the values within the ROWS above cells in a range, and I can't get that to work. For example, I tried this and it didn't work:
=If(AND(E30>A:A,E30<B:B), "TRUE", "FALSE")
I also tried a simple countif variation but that didn't do it either:
=COUNTIFS(A:A,">"&E30,B:B,"<"&E30)
Any advice on how to adjust one of these formulas to get it to work?
Try switching the angle brackets around:
=COUNTIFS(A:A,"<"&E30,B:B,">"&E30)
I think this should work for the above data set -
=IF((FILTER(A2:B6, D2>A2:A6,D2<B2:B6)),TRUE,FALSE)
This will give you if there is any match or not.
For the number of rows count that match -
=ROWS((FILTER(A2:B6, D2>A2:A6,D2<B2:B6)))
Alomsot =IF(Q2>R2,IF(AND($X$16>HOUR(Q2),$X$16<(HOUR(R2)+12)),1,0),IF(AND(HOUR($X$14)>=HOUR(Q2),HOUR($X$14)<=HOUR(R2)),1,0))
I have been struggling to return the count of courses from this XML file that contain "Cross-listed" as their description. The problem I encounter is because I am using for, it iterates and gives me "1 1" instead of "2". When I try using let instead I get 13 which means it counts all without condition even when I point return count($c["Cross-listed"]. What am I doing wrong and how can I fix it? Thanks in advance
for $c in doc("courses.xml")//Department/Course
where some $desc in $c/Description
satisfies contains($desc, "Cross-listed")
return count($c)
The problem I encounter is because I am using for
You are quite correct. You don't need to process items individually in order to count them.
You've made things much too difficult. You want
count(doc("courses.xml")//Department/Course[Description[contains(., "Cross-listed"]])
The key thing here is: you want a count, so call the count() function, and give it an argument which selects the set of things you want to include in the count.
I am using the predefined "WindSpeedData" function, which returns a TimeSeries object. How can I get the variable names that constitute the time series and their corresponding data?
Found the answer.
Use "Values[WindspeedData[...]] "
I have a couchdb view set up using an array key value, in the format:
[articleId, -timestamp]
I want to query for all entries with the same article id. All timestamps are acceptable.
Right now I am using a query like this:
?startkey=["A697CA3027682D5JSSC",-9999999999999]&endkey=["A697CA3027682D5JSSC",0]
but I would like something a bit simpler.
Is there an easy way to completely wildcard the second key element? What would be the simplest syntax for this?
First, as a comment pointed out, there is indeed a special value {} that is ordered after any value, so your query becomes:
startkey=["target ID"]&endkey=["target ID",{}]
This is as equivalent to a wildcard match.
As a side note, there is no need to reverse the ordering in the map function by emitting a negative timestamp, you can reverse the order as an option to the view invocation (your start and end key will be swapped).
startkey=["target ID",{}]&endkey=["target ID"]&descending=true
For future reference, in CouchDB 3 you can use "\ufff0" instead of {}, which would be ordered after a string or number, but before an object.
From the CouchDB 3 docs:
Beware that {} is no longer a suitable “high” key sentinel value. Use a string like "\ufff0" instead.
The query startkey=["foo"]&endkey=["foo",{}] will match most array keys with “foo” in the first element, such as ["foo","bar"] and ["foo",["bar","baz"]]. However it will not match ["foo",{"an":"object"}]