0
I need to take only the months of the dates of a given field that is in my database, however, preferably without using SELECT MONTH.
That way, we get the current month of today’s date:
$mes_atual = date('m');
echo $mes_atual; //Seria exibido "06" - hoje é dia 22/06/2020
I was looking for something similar, but with the bank dates, I’m going to leave an example that I know doesn’t make much sense, but just so you understand better.
My example code:
$sql = "SELECT prazo FROM comercio";
$resultado = mysqli_query($con, $sql);
while ($row= mysqli_fetch_array($resultado)) {
$mes_atual = date('m')$row['prazo']; //Aqui pegaria somente o mês das datas vindas do banco
}
Is it possible I rescue these months from database otherwise? without being using the SELECT MONTH, if NAY, why?
Either you recover the full date of your DBMS and extract the month in your application or just recover the month using the function
month, from your DBMS and delivers only the month to your application. I couldn’t understand your final question. Obviously the less data you traffic on the network the more efficient your application will be.– anonimo
@anonymous in my post, basically I’m asking if there are other ways to rescue only the month of a date that is in the database (Mysql), without using the
SELECT MONTH– Samuel Verissimo
What’s wrong with "Month" ?
– Motta
SELECT term FROM trade Where Month(now()) = Month(term) would be this ?
– Motta
No, it is displayed the current month and then the bank date... This example code is to say that I want to take only the month of this bank date. I’m managing to solve the problem and I’ll post the answer here, but I had nowhere to run...
– Samuel Verissimo
Explains but doesn’t make it complicated. First you say //It would be displayed "06" - today is day 22/06/2020 -- then you say //Here would take only the month of the dates coming from the bank. So it’s today or all the dates?
– user60252
I understood a thing.
– Motta
@Leocaracciolo of all the dates they have in the field of the bank, sorry if I was unclear, but the POST was solved.
– Samuel Verissimo