Jump to content

whats wrong with this query? How can I fix it


TeddyKiller

Recommended Posts

$getEvent_res = mysql_query("SELECT event_title, event_shortdesc, date_format(event_start, '%l:%i %p') as fmt_date, date_format(event_end, '%1:%1 %p') as end_date FROM calendar_events WHERE month(event_start) = '".$m."' AND dayofmonth(event_start) = '".$d."' AND year(event_start) = '".$y."' AND calendar = '1' ORDER BY event_start") or die(mysql_error());

 

Sorry it's a bit messy. The bit with the problem, is here.

date_format(event_start, '%l:%i %p') as fmt_date, date_format(event_end, '%1:%1 %p') as end_date

 

echoing fmt_date, works perfectly. Although echoing end_date doesn't work.

Can you help? I know it's slightly SQL related.. but wasn't quite sure where i'd exactly put it as there could be a PHP solution.

 

Cheers

I've not used date_format() in a database query before. but, I do notice that you are using it differently:

 

date_format(event_start, '%l:%i %p') as fmt_date

[uses the letter L and and the letter I]

 

date_format(event_end, '%1:%1 %p') as end_date

[uses the number 1 both times]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.