Time and date both are different fields but when I use this coding result is not perfect.
This is my code:
$challenges = Challenge::whereDate('c_date','>',Carbon::now())->get();
Challenge::whereTime('c_time','>',Carbon::now())->get();
Are there any problems in this code?
Firstly check the formate of date in c_date.Format should be ('Y-m-d').If your formate is okay then check your logic that what you really want?
I think your fault is your logic .You want to get those date where c_date is grater then now date.
$challenges = Challenge::whereDate('c_date','<',Carbon::now())->get();
Related
I want something like this - where the date could be empty:
{$VERTRAGSDATUM|date_format:"%d.%m.%Y"|default:'________________'}
But it gives me only "Undefined index" errors.
When changing the order to default at first it gives me the current date. :-/
I've a lot of this date fields and don't want to ask if isset... so is there perhaps a simple solution?
I am trying to track stock prices with Googlefinance function in Sheets. I can pull the price for a date with =INDEX(GOOGLEFINANCE((B2),"price",date(2019,12,13)),2,2) which is fine but I want to input the date with Column A which has date data. So, (A1) instead of (2019,12,13)but for some reason I get errors.
This seems simple but I cannot get it to pull the date from my column. Ive tried removing DATE and just using the cell but this also doesnt work.
the formula that worked for me is
=index(GOOGLEFINANCE("YOUR_STOCK", "price",A1),2,2)
If, like you said, you already tried that and it did not work, you should link us a test sheet with your formula.
make sure A1 is really a date. you can check this with
=ISDATE(A1)
the output should be TRUE. your formula is correct:
=INDEX(GOOGLEFINANCE(B2; "price"; A1); 2; 2)
Im working in a project where I display different events in my view. The goal for now is to only show events that are upcoming, so it doesn't show events that are older than today.
The users of my page can create an event and set a sertain date for it.
The data is stored into my db like this:
$table->string('datum');
In the view it return it like this:
06.03.2019
My controller to return the data looks like this:
$date = date('d.m.Y');
$evententries = Event::where('datum', '>=', $date)->orderBy('datum', 'asc')->take(3)->get();
but it's somehow not working..
Anyone got any Ideas of how to fix this and what my issue is here?
btw, I'm using laravel 5.7.
Thank you :)
Hmm you are doing it on wrong way from begin...
First: why you are using string to store date value? there is much better options to store date within database...
Second: you are using date format which cannot be compared on that way (using < > =)
when you are comparing strings ie 08.03.2019 will be always smaller than 10.01.2016 because 1 > 0... so if you are comparing dates use:
db format for storing dates
for comparing use format yyyy-mm-dd because on that way even simple string comparison will give you correct result...
FILTER("source"."recordCount" USING "source"."snapshot_date" =
EVALUATE('TO_CHAR(%1, ''YYYYMMDD'')', TIMESTAMPADD(SQL_TSI_DAY, -7, EVALUATE('TO_DATE(%1, %2)', "source"."snapshot_date" , 'YYYYMMDD'))))
So i have this piece of code here. I know some will say "Just use the AGO function" But somehow it's causing problems because of it's connection with other tables so what I'm trying to achieve here is like a remake. The process goes this way:
The snapshot_date there is actually in varchar format and not date. So it's like "20131016" and I'm trying to change it to a date then subtract 7 days from it using the TIMESTAMPADD function and then finally returning it back to varchar to use it with FILTER.
This snippet somehow works when testing the FILTER using hardcoded values like "20131016" for example but when tested out with the code above all the row are blank. On paper, the process i assumed would happen goes lke this. "20131016" turns to a date with a format of 20131016 (yyyymmdd) and then less 7 days: 20131009 and then turned into char again "20131009" to be used in the filter.
But somehow that doesn't happen. I think the data format is not applying either to the string->date or the date->string conversion. which results to the values not getting a match at all.
Anyone have any idea what's wrong with my code?
By the way I've already tried to use CAST instead of EVALUATE or TO_TIMEDATE with the same result. Oh and this goes to the formula of the column in BMM.
Thanks
You might get some clues by looking at the SQL generated by the BI Server. I can't see any issues with your column expression, so I wouldn't limit your debugging to that alone.
A query returning nulls is often caused by incorrect levels being set (especially on logical table sources, but potentially on a measure column too). This will often result in some form of SELECT NULL FROM ... in the physical SQL.
Try this :
FILTER("source"."recordCount" USING "source"."snapshot_date" =
EVALUATE('TO_CHAR(%1, %2)', TIMESTAMPADD(SQL_TSI_DAY, -7, EVALUATE('TO_DATE(%1, %2)', TO_CHAR("source"."snapshot_date" , 'YYYYMMDD') , 'YYYYMMDD')) , 'YYYYMMDD'))
I need a php function that can randomly select one row that has a unix time date field (like 2011-11-12 or 2011-12-24) that indicates the row was created within the last two weeks from a mySQL table and return the id of that said row.
I don't know how do this. Honestly, I would like someone to hand me the code, but I don't like that because most people don't like that.. and their reasons make sense, but if someone would show me the code, then please do, thus can someone at the least point me in the right direction? Thank you.
You can get the date by using date and strtotime:
$date = date('Y-m-d', strtotime("-2 weeks"));
Then the query would look something like this:
SELECT * FROM table WHERE date_field >= '$date' ORDER BY RAND() LIMIT 1;
ORDER BY RAND() gives you a random row.
strtotime: http://us3.php.net/manual/en/function.strtotime.php
Hope this helps. :)