Compare two dates in Mysql stored in a varchar field

by Rekha 2010-11-09 12:51:43

Compare two dates in Mysql stored in a varchar field

If you have stored date in a varchar field instead of date field and want to compare two dated and fetch result, normal date comparison like date>='2010-11-09' won't work. You have to use STR_TO_DATE() function.

STR_TO_DATE(date, '%d-%m-%Y')>='2010-11-09'

Tagged in:

1479
like
0
dislike
0
mail
flag

You must LOGIN to add comments