Copy link to clipboard
Copied
I am having trouble formatting the date with php/MySQL in a filtered recordset. I am looking at the tutorial on http://forums.adobe.com/thread/450108 which shows how to do it. I've gotten it to work for a regular query but it sends back errors when I try to insert it into a filtered recordset. Here is the code I am trying but it's not working.
$blog_id = "-1";
if (isset($_GET['blog_id'])) {
$blog_id = $_GET['blog_id'];
}
$query_blog_comments = sprintf("SELECT blog_id, blog, comment, display, DATE_FORMAT(date, '%W, %M %e, %Y') AS date_formatted FROM blog_comment WHERE blog_id = %s AND display = 1 ORDER BY blog_id ASC", GetSQLValueString($blog_id, "text"));
Please tell me how to format a date for a filtered recordset. Thanks!
Heya,
Try this code:
$blog_id = "-1"; if (isset($_GET['blog_id'])) { $blog_id = $_GET['blog_id']; } $query_blog_comments = sprintf("SELECT blog_id, blog, comment, display, DATE_FORMAT(date, '%%W, %%M %%e, %%Y') AS date_formatted FROM blog_comment WHERE blog_id = %s AND display = 1 ORDER BY blog_id ASC", GetSQLValueString($blog_id, "text"));
The difference is an extra '%' placed in each date variable of DATE_FORMAT
Copy link to clipboard
Copied
Heya,
Try this code:
$blog_id = "-1"; if (isset($_GET['blog_id'])) { $blog_id = $_GET['blog_id']; } $query_blog_comments = sprintf("SELECT blog_id, blog, comment, display, DATE_FORMAT(date, '%%W, %%M %%e, %%Y') AS date_formatted FROM blog_comment WHERE blog_id = %s AND display = 1 ORDER BY blog_id ASC", GetSQLValueString($blog_id, "text"));
The difference is an extra '%' placed in each date variable of DATE_FORMAT
Copy link to clipboard
Copied
It works! Thank you so much.