Hazy McGee
Hazy McGee

Reputation: 12102

MySQL / PHP / SugarCRM Scheduling

And I'm back with new questions. There's probably an easy query to figure out what I need.

I have SugarCRM and I'm using a SOAP WebUI to create meetings on the calendar

Im trying to figure out how I can check to see if the time between meetings.date_start and meetings.date_end is taken already.

Currently I can check if the date I'm entering from the web form is EQUAL to the meetings.date_start with this query:

$query="select id, date_start, date_end from meetings where  date_start='$dateToCheck' AND assigned_user_id='$stylist'";

where $dateToCheck is in DateTime format

using:

$resource=mysql_query($query,$connect)
if(mysql_num_rows($resource)>0)
{
        echo '<script type="text/javascript">';
        echo 'alert("Time is Taken.");';
        echo '</script>';
}

I can check that the $dateToCheck = date_start

so for example if i have an appointment that starts at 9:30 am and ends at 10:45 I CANT create an appointment for 9:30 but I CAN for 9:45

Any suggestions?

Upvotes: 0

Views: 343

Answers (1)

bitoshi.n
bitoshi.n

Reputation: 2318

Try this

select id, date_start, date_end 
from meetings 
where  date_start<='$dateToCheck' 
    AND date_end>='$dateToCheck' 
    AND assigned_user_id='$stylist'

Upvotes: 1

Related Questions