How to Convert MySQL Date within MySQL Query?
I have a query from within my vb.net code which searchs for a record by date. The date being entered via the code is in format开发者_开发知识库 dd/mm/yyyy, i need to search in the database using yyyy/mm/dd?
Ideally i thought there may just be a function within MySQL which will convert this. If not in vb.net to convert the string 01/01/2011 to 2011/01/01?
Thanks
Take a look at str_to_date() function
select str_to_date('01/01/2011','%d/%m/%Y')
So, your search becomes
select * from table where date_field = str_to_date(your_variable,'%d/%m/%Y')
精彩评论