Fetching Data by Date from mysql
I have mysql db that has date in string format. Now I want to fetch data month wise. What would be the mysql to fetch data.
First suggestion would be to store your dates as DATE or DATETIME (or possibly TIMESTAMP) types in the database, making things much, much easier. If for some reason that is not feasible -- and you better have a really good reason that I frankly can't imagine -- then you would probably have to make use of MySQL's STR_TO_DATE() function to convert on the fly, then use the result as needed, perhaps in a BETWEEN statement.
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
Thanks a lot, It works for me
The correct function of mysql is ORDER BY FROM_UNIXTIME(date_in_string_format) ASC
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Tags for this Thread