PDA

View Full Version : including formatted date with sprintf


mr_badger
01-16-2011, 07:04 PM
Hi,
I want to format the date for a site I have done but cant get it to work with sprintf so I'm hoping someone can help me.

the code I have is this
$query_report_full = sprintf("SELECT * FROM reports WHERE report_id = %s", GetSQLValueString($colname_report_full, "int"));

I have been using this but doesnt work
$query_report_full = sprintf("SELECT *, DATE_FORMAT(report_date, '%b %e, %Y') AS report_date FROM reports WHERE report_id = %s", GetSQLValueString($colname_report_full, "int"));

hope someone can help

thankyou

davidj
01-31-2011, 11:30 AM
can you run the SQL in the command line to see if it returns a value?

mr_badger
02-12-2011, 03:09 PM
Hi
Sorry for the long delay in replying, but in answer to your question I get a no query returned message when I run the page, hope this helps?

davidj
02-15-2011, 09:59 AM
take this...

SELECT *, DATE_FORMAT(report_date, '%b %e, %Y') AS report_date FROM reports WHERE report_id = 'xxx'

add an actual value where I placed xxx

open PHPMyAdmin (or whatever tool you use) and run it.

You can run it from the command line quite easily