I am not sure how to do this, how ever what I have is
Model::where('id', $id);
thats it, thats all I have. I am not sure how to do:
Model::where('id', $id)->where(between today and 25 days ago);
Ideas?
Model::where('created_at', '>' , Carbon::now()->subDays(25))
Related
I am trying to relieve data from my database that will only return data that will be due in the next 6 months.
In my controller, this is how I query my database.
$critical = infrastructure::where("inf_lifspan",">", Carbon::now()->subMonths(6))->get();
The results is shown below.
Can someone point me in the right direction what I did wrong?
Thanks.
Thanks guys, I got the answer. I just need to change the > sign to < sign.
$critical = infrastructure::whereDate('inf_lifspan','<', Carbon::now()->addMonths(6))->get();
I am trying to get the difference between two dates in months for an xPath.
I have no problems getting it in days (1127)
days-from-duration(xs:date('2012-06-17')-xs:date('2009-05-17'))
When I try doing it in months I get 0
months-from-duration(xs:date('2012-06-17')-xs:date('2009-05-17'))
I did notice that this comes back as days only ("P1126D") so that maybe the problem just not sure how to fix it.
xs:date('2012-06-17')-xs:date('2009-05-17')
Thanks for any help!
So the best thing I can seem to do is manually calculate it.
(year-from-date(xs:date('2012-06-17')) - year-from-date(xs:date('2012-05-18')))*12 + month-from-date(xs:date('2012-06-17')) -month-from-date(xs:date('2012-05-18')) + (if (day-from-date(xs:date('2012-06-17')) < day-from-date(xs:date('2012-05-18')) ) then -1 else 0)
This function was not included in the spec because we couldn't agree semantics for it. We heard arguments that the difference between 31 March 2015 and 30 Sept 2015 was six months, and arguments that it was five months. (Advice: negative differences seem to be even more problematic than positive differences.) You can easily find that a date plus 6 months minus 6 months is not the date where you started. You'll have to define what you think the answer should be, and implement it using lower-level facilities such as month-from-date and year-from-date.
The problem is that days-from-duration returns the days field -- not the number of days the duration includes. Likewise for months and years.
Now, you can divide by days, but not by months (since months have uneven boundaries):
(: arg1 here is a dayTimeDuration, which can't be easily converted to a yearMonthDuration :)
let $arg1 := xs:date('2012-06-17')-xs:date('2009-05-17')
return xs:dayTimeDuration($arg1) div xs:dayTimeDuration("P30D")
I'm trying to use a relatively basic IF function but having no luck - i'm sure i just have brackets or parenthesis wrong or something. Reckon it will be childsplay for you guys....
The formula is intended to show how many days a date has passed by. Date is shown in T column.
Basically it was working fine as the following, both for pending and past dates:
=IF(T7<=TODAY(), (TODAY()-T7),-(T7-TODAY()))
But I got greedy and wanted it to return more of a statement when the date has passed, as to how much it has passed by. So I've tried to make this happen with:
=IF(T7<=TODAY(),"EffOut(TODAY()-T7) days ago",-(T7-TODAY()))
Hoping it would enter "EffOut 8 days ago" (when TODAY()-T7 is 8 days) for example.
But it doesnt - it shows the entire argument i.e "EffOut(TODAY()-T7) days ago" in the return cell.
Is it possible to have a kind of embedded formula in the 'value_if' fields, mixed with text in this sense?
Happy to share the document if that would help, but will need to clear the data first so just let me know.
Thanks in advance, any help is much appreciated! Having read other posts I think it will just be a simple fix but its well beyond me! (I only got this far by perusing forums...)
Maybe something like this...
=IF(T7<=TODAY(),"EffOut "&DAYS(TODAY(),T7)&" days ago",-(T7-TODAY()))
=IF(T7<=TODAY(),"EffOut "&(TODAY()-T7)&" days ago",-(T7-TODAY()))
You just need to be careful to put "" around any strings. This is how Excel knows that's not a part of the formula. Remember to out the spaces is to the string like I did above so it looks like a sentence. The & sign combines the results of the calculated parts and the strings.
I don't see anything on the oracle docs saying how to change the formatting of the output of a numtodsinterval function so I was hoping you could help
EXTRACT(MINUTE FROM NUMTODSINTERVAL(TOTAL_HOURS, 'HOUR'))
I would like this to come out in a two digit format :'MM', now it works in converting 1.25 into 1:15 but if the time is 8.1333 it displays 8:8
thanks!
Hey sorry yes you're right, I had not given enough information, I did want to display it in typical time fashion HH:MM, and also you are right it does return a number, I did not have a to_char , adding it made this a simple problem to solve so thank you!
Drools seems to support only days, hours, minutes, seconds and milliseconds for the units of time used with Temporal Operators. I am working on a rule that looks for people within a particular age group. For example: between 6 months and 5 years, younger than 18 years, older than 12 years etc..
My person Class has a dateOfBirth instance variable, but no person.age method to do a direct comparison like:
$p : Person(age <= 18)
I don't have too much liberty to modify the Person Class and I am trying to avoid writing utils methods and using 'eval' for comparing, as 'evals' are not optimized. I am a drools newbie and have written the following rule.
rule "Under18Years"
when
now : RuleTime()
$p : Person(dateOfBirth after[-6570d, 0s] $now )
then
System.out.println("Under18Years fired");
end
I know this isn't very accurate as I just used 6570 (365*18) days; ignoring the leap years. I might be better off using seconds in a standard SI year (31,556,926) times 18 to account for 18 years, but is there a better way? This doesn't work for conditions involving months either. Does anyone have any other ideas/solution to this problem?
You can create a package or a function that does the above
public int getAge() {
Years years = Years.yearsBetween(dateOfBirth, currentDate);
return years.getYears();
For aslong as i have been using drools there has allways been years available to call upon. i see this was posted a while ago and maybe you have found out since.