javaprogrammer javaprogrammer - 11 months ago 46
SQL Question

How to insert the date as string into a single column for all rows?

The code below is not completing the required task. I have a table called payslip with a column called date, where I want to fill all entries in the column "date" with the current date, how to do this?

String date = new SimpleDateFormat("yyyy.MM.dd").format(new java.util.Date());
PreparedStatement ps0= con.prepareStatement("INSERT INTO payroll_system.payslip(date) VALUES(?)");
ps0.setString(1, date);


If you want the current date, then just use the value on the database server:

update payroll_system.payslip
    set date = curdate();