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

Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.