Quote:
Originally posted by aus
You can get the date formatted the way you want with the function DATE_FORMAT. Use it like this:
SELECT DATE_FORMAT(datetime_col, "%M %e, %Y") FROM table1;
|
thanks, it works if I query the db seperately.
But when I construct this into a SQL statement inside a jsp page, it is not.
How do I specify the format?.
my statement looks like this
<%
String dateStart = request.getParameter("dateStart") ;
String dateEnd = request.getParameter("dateEnd") ;
String sql = "select firstname, email, (date_format(loginpw.expires_dtime, %M, %D, %Y )), amount"
+ " from loginpw pw "
+ "left join payments pt on pw.loginpw_id = pt.loginpw_id "
+ " where expires_dtime >= " + dateStart
+ " and expires_dtime <= " + dateEnd ;
Result result = csuser.execute(csuser.newStatement(sql));
%>