我正在使用jquery模板做一个项目,它有一个datepicker,格式为11/01/2015 (month/date/year)
,但是当我将它添加到数据库时,它不会给出任何违反模式的输出原因。谁能告诉我如何改变它
2015-11-01 (year-month- date)
我用过这个,但它没有用
SELECT DATE_FORMAT(inventory_dateTime,'%d-%m-%Y')
FROM `db_thisurienterprice`.`tbl_inventory`
where inventory_dateTime between '11/30/2014' and '11/30/2015'
答案 0 :(得分:1)
因为您需要转换字符串'11/30/2014'
& '11/30/2015'
到目前为止您可以使用str_to_date
函数轻松转换它,所以请将您的查询更新为
SELECT DATE_FORMAT(inventory_dateTime,'%d-%m-%Y') FROM
db_thisurienterprice.tbl_inventory where inventory_dateTime between
str_to_date('11/30/2014', '%m/%d/%Y') and str_to_date('11/30/2015', '%m/%d/%Y')
答案 1 :(得分:0)
SELECT DATE_FORMAT(`inventory_dateTime`,'%d-%m-%Y') FROM `db_thisurienterprice`.`tbl_inventory` where inventory_dateTime between '2015/10/09' and '2015/10/17'