2
I have a date field (type VARCHAR) in my table, and recently I needed to search the database with date range.
And for that I used the operator Between, getting something like: BETWEEN 15/08/2015 AND 25/08/2015. So far so good.
The problem is when I need to search from one month to another, something like: BETWEEN 25/07/2015 AND 25/08/2015, ai does not work, and I believe faithfully that this is due to the problem of the field date be of type VARCHAR and not the date type.
I am willing to change the format of the dates to 0000-00-00, the problem is that when capturing this data I cannot show in this format, since here the default is 00/00/0000.
Well, I need to solve this, as I do to conform the format 0000-00-00 in 00/00/0000, or another way to search the range of records, in order not to use the date field for this.
Really I would convert the guy but to solve the search tried
STR_TO_DATE(data, '%d-%m-%Y')? If this is the format your date is in.– Maniero
Solves part of the problem Convert Mysql data dd/mm/yyyy to yyyy-mm-dd
– rray
If you plan to change the date format, it is not better to change the field type to
DATE, then? That would solve all your problems and the bank remains consistent.– Rodrigo Rigotti