Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

DATE_FORMAT in filtered recordset

New Here ,
Sep 29, 2009 Sep 29, 2009

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!

TOPICS
Server side applications

Views

525
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Advisor , Sep 30, 2009 Sep 30, 2009

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

Votes

Translate
Advisor ,
Sep 30, 2009 Sep 30, 2009

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

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 30, 2009 Sep 30, 2009

Copy link to clipboard

Copied

LATEST

It works! Thank you so much.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines