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

"Too Few Arguments" error when using Date Format

New Here ,
Dec 21, 2011 Dec 21, 2011

Copy link to clipboard

Copied

I'm attempting to format some date information. I'm taking the following query:

mysql_select_db($database_adventcms, $adventcms);

$query_rsDatedetails = sprintf("SELECT * FROM tbEvents WHERE id = %s", GetSQLValueString($colname_rsDatedetails, "int"));

$rsDatedetails = mysql_query($query_rsDatedetails, $adventcms) or die(mysql_error());

$row_rsDatedetails = mysql_fetch_assoc($rsDatedetails);

$totalRows_rsDatedetails = mysql_num_rows($rsDatedetails);

and changing it to this:

mysql_select_db($database_adventcms, $adventcms);

$query_rsDatedetails = sprintf("SELECT *, DATE_FORMAT(datestart, '%b') AS whichMonth, DATE_FORMAT(datestart, '%Y') AS whichYear, DATE_FORMAT(datestart, '%D') AS whichDate FROM tbEvents WHERE id = %s", GetSQLValueString($colname_rsDatedetails, "int"));

$rsDatedetails = mysql_query($query_rsDatedetails, $adventcms) or die(mysql_error());

$row_rsDatedetails = mysql_fetch_assoc($rsDatedetails);

$totalRows_rsDatedetails = mysql_num_rows($rsDatedetails);

When I run it I get this error:

Warning: sprintf() [function.sprintf]: Too few arguments in /home/iasindia/public_html/beta/newsandevents/eventdetails.php on line 60

Query was empty

which refers to the query line above. The odd thing is that same query works on a different query like this:

$query_rsDates = "SELECT *, DATE_FORMAT(datestart, '%b') AS whichMonth, DATE_FORMAT(datestart, '%Y') AS whichYear, DATE_FORMAT(datestart, '%D') AS whichDate FROM tbEvents WHERE status = 'Live' AND datestart >= CURDATE() ORDER BY datestart DESC";

$query_limit_rsDates = sprintf("%s LIMIT %d, %d", $query_rsDates, $startRow_rsDates, $maxRows_rsDates);

$rsDates = mysql_query($query_limit_rsDates, $adventcms) or die(mysql_error());

$row_rsDates = mysql_fetch_assoc($rsDates);

But I can't get it to work on the $query_rsDatedetails above.

Any help would be appreciated!


TOPICS
Server side applications

Views

1.1K
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
LEGEND ,
Dec 22, 2011 Dec 22, 2011

Copy link to clipboard

Copied

LATEST

The sprintf function is interpreting the date format type as an input. There are several solutions:

http://stackoverflow.com/questions/5835534/mysql-query-date-format-and-sprintf

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