I allow users to enter dates as 15-10-2010 and 15/10/2010. Problem is, I can only specify one separator type in mysql'开发者_Python百科s str_to_date. So if a user enters 15-10-2010, then STR_TO_DATE('15-10-2010','%d-%m-%Y') would work fine. But if the user did 15/10/2010, I get a null value in the database column. Is there a way to tell mysql to all both - and / as the seperator?
You could use the Replace function in mysql.
Something like this:
STR_TO_DATE(REPLACE('15/10/2010', '/', '-'), '%d-%m-%Y')
Hope this helps, Arne
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论