mr cracker Posted May 2, 2010 Share Posted May 2, 2010 Hello. I´m having a problem with this Query: $fecha=$_POST['fecha']; $result = mysql_query("SELECT * FROM tbl_ventas WHERE fecha = (str_to_date('$fecha', '%d/%m/%Y')"); but it returns an error in MYSQL Syntax. The variable $fecha contains the date the user selects from a calendar in this format in example: 1-5-2010 (d/m/y). i want to convert that date format into MySQL´s YYYY-mm-dd so i can then select only the matching records in the table tbl_ventas. THANKS! Link to comment https://forums.phpfreaks.com/topic/200412-str_to_date-problem/ Share on other sites More sharing options...
Ken2k7 Posted May 2, 2010 Share Posted May 2, 2010 Oops. Link to comment https://forums.phpfreaks.com/topic/200412-str_to_date-problem/#findComment-1051715 Share on other sites More sharing options...
PFMaBiSmAd Posted May 2, 2010 Share Posted May 2, 2010 You have an extra ( in your query before the mysql str_to_data() function that is probably producing a sql syntax error. It would help if you post errors you are getting as they generally point to where a problem is occurring at and result in quicker solutions. Link to comment https://forums.phpfreaks.com/topic/200412-str_to_date-problem/#findComment-1051716 Share on other sites More sharing options...
mr cracker Posted May 2, 2010 Author Share Posted May 2, 2010 THank you! i hadn´t noticed the extra bracket. sorry. its working now Link to comment https://forums.phpfreaks.com/topic/200412-str_to_date-problem/#findComment-1051736 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.