如何使用java在SQL Workbench中存储数据时间?我试过但是未能这样做。想要使用Java在Order Column中插入当前日期时间
insert into customer_order (idCustomer_Order,Customer_id,Total_Amount,Payment,Order_date,Order_month,Order_year,Delivery_date,Delivery_month,Delivery_year,product_id,OrderDate)value(3,1,122,'payed',3,2,4,2,3,4,4,curdate())
我试过这个,但时间是00:00:00 3 1 122付3 2 4 2 3 4 4 2017-12-28 00:00:00
使用NOW()
,它将添加当前日期时间
您的查询应采用表单
INSERT INTO customer_order (idCustomer_Order,Customer_id,Total_Amount,Payment,Order_date,Order_month,Order_year,Delivery_date,Delivery_month,Delivery_year,product_id,OrderDate)value(3,1,122,'payed',3,2,4,2,3,4,4, NOW())
我正在使用curDate(),所以只有日期插入数据库,而不是我使用current_timestamp(),而不是我得到日期和时间。
insert into customer_order (OrderDate)value(current_timestamp())
输出是2017-12-28 01:48:31