Jump to content

Date


Recommended Posts

Hi,

 

I have a query that shows all appointments of a chosen day using the following format:

 

$eventid=2007-05-21

 

WHERE starttime LIKE '".$eventid."%'

 

I have a calendar and am trying to make it show all records for the selected month, or display all records from a specific day if a day is selected from the calendar.

 

So far I have it where I can show records from specific day, but want selected months records as default.

 

 

Thanks

 

Link to comment
Share on other sites

Hi,

 

Its stored as "datetime"

 

Im looking more for an if statment I think.

 

if(isset($eventid)){

$eventid = 2007-05-21

}else{

$eventid = selected_month

}

 

Not sure really, trying to keep it simple.

 

Just not sure how to grab all records = to 5th month or 6th month. The variable passed is "2007-05-21"

 

maybe use explode and the date parts?

 

Thanks

Link to comment
Share on other sites

Hmm

 

Tried a few ways, no success:

 

$eventid=2007-05-21

 

$sql = mysql_query("SELECT id, firstname, lastname, phone, cellphone, email, MONTH(starttime) -> 2, finishtime, event FROM calendar WHERE starttime LIKE '".$eventid."%' ORDER BY starttime ASC");

 

Trying to pull all records for the 5th month.

 

 

Thanks

Link to comment
Share on other sites

erm.. whats

MONTH(starttime) -> 2

 

try

<?php
$eventid=2007-05-21; //only uses the 05
$sql = mysql_query("SELECT id, firstname, lastname, phone, cellphone, email, finishtime, event FROM calendar WHERE MONTH(starttime) = MONTH($eventid), ORDER BY starttime ASC");
?>

Link to comment
Share on other sites

That was from the manual

 

I have tried a few ways with no success. Brings back no matches:

 

$sql = mysql_query("SELECT id, firstname, lastname, phone, cellphone, email, starttime, finishtime, event FROM calendar WHERE MONTH(starttime) LIKE 'MONTH(".$eventid.")%'");

 

Must be close, all makes sence.

 

 

Thanks

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.