I'm trying to execute a query in SQL where I need the day, month and year of "today".
INSERT INTO Facture (Date_Achat,Remise, Acompte, Mode_De_Paiement, N°Client) VALUES (Date(Now()), "
+s6+","+ s7 +" ,'"+s8+"' ,"+s1+"); "
However Date(Now) doesn't work and I tried this in order to put "actuelle" in place of Date(Now()) but doesn't work. So, how can I "replace" Date(Now()) in the following statement by today's date BUT only day, month and year?
Date actuelle = new Date();
//String dat = dateFormat.format(actuelle);
SimpleDateFormat formatter= new SimpleDateFormat("yyyy-mm-dd");
Calendar today = Calendar.getInstance();
today.set(Calendar.DAY_OF_MONTH,Calendar.MONTH,Calendar.YEAR);
try {
actuelle = formatter.parse(today.toString());
}
catch (ParseException ex) {
Logger.getLogger(CréationFacture.class.getName()).log(Level.SEVERE, null, ex);
}
Thanks!
Date_Achatcolumn, and what specifically happens when you run your query -- does it return an error message, does it insert data you don't want? "Doesn't work" is not helpful.PreparedStatements. Then this date formatting mess becomes superfluous anyways.