therealssj
therealssj

Reputation: 153

Retrieve data with different datatype

I am storing data in my table with char datatype but there are date values also. The table has only 3 columns Name Field Content The problem comes when i try to retrive dates from the data and have them in ascending or descending order since mysql treats them as strings instead of dates the output isnt quite correct. Is there anyway i could retrieve the dates telling mysql to treat them as dates and not strings?

Upvotes: 1

Views: 35

Answers (1)

John Ruddell
John Ruddell

Reputation: 25842

thats probably because it is not a datetime datatype in the database.. its a string.. use the STR_TO_DATE() function to convert it to a date.

Upvotes: 1

Related Questions