How to convert a date that is in string format to the database when doing a query?

1

I have a date that is in string format in the "dd/MM/yyyy" database and I needed to return in my query the dates from today. How can I do this query conversion to compare with today? Thank you in advance!

update: I am using the minha_data > date('now') command I have 3 dates on my bank 2/7/2015, 12/3/2015 and 3/3/2016, but it is returning only the last date, it should return the last 2.

    
asked by anonymous 07.10.2015 / 15:24

2 answers

1

It is very likely that the result of date('now') will not come in the format dd / mm / yyyy (the default is yyyy / mm / dd ).

You can apply a formatting with strftime() so that the return of date() is in the format that your dates are saved.

minha_data > strftime('%d/%m/%Y', date('now'));
    
07.10.2015 / 16:15
0

In php use:

echo date('d/m/Y')

Another question, why are you using it in local format? Is this set up in the bank? Generally date fields in the database use the type of the DATE field, this will give you the possibility of comparing date ranges, if your field is like VARCHAR it is probably wrong or your usage is specific to that.

    
07.10.2015 / 19:19