TeddyKiller Posted April 13, 2010 Share Posted April 13, 2010 $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 Link to comment https://forums.phpfreaks.com/topic/198422-whats-wrong-with-this-query-how-can-i-fix-it/ Share on other sites More sharing options...
Ken2k7 Posted April 13, 2010 Share Posted April 13, 2010 What types are event_start and event_end in the database? Link to comment https://forums.phpfreaks.com/topic/198422-whats-wrong-with-this-query-how-can-i-fix-it/#findComment-1041198 Share on other sites More sharing options...
Psycho Posted April 13, 2010 Share Posted April 13, 2010 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] Link to comment https://forums.phpfreaks.com/topic/198422-whats-wrong-with-this-query-how-can-i-fix-it/#findComment-1041215 Share on other sites More sharing options...
TeddyKiller Posted April 13, 2010 Author Share Posted April 13, 2010 Ah. that was the issue MJDamato. Cheers Link to comment https://forums.phpfreaks.com/topic/198422-whats-wrong-with-this-query-how-can-i-fix-it/#findComment-1041221 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.