3063 Posts in 864 Topics by 646 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 300 Views |
-
Using SQL BETWEEN and AND together in DataObject::get

13 January 2012 at 9:04am
Greets,
I am trying to return "Appointment" DataObjects in the morning in one function, and then in the afternoon in another. It's throwing an error due to the double "and"'s in the statement. I have never used BETWEEN before in SS.
DataTypes being used are Date and Time.
function getMorningAppointments() {
$today = date('Y-m-d');
$appointments = DataObject::get("Appointment", "`Date` = '{$today}' AND `Time` BETWEEN '07:00:00' AND '11:59:59'");
return $appointments;
}
function getAfternoonAppointments() {
$today = date('Y-m-d');
$appointments = DataObject::get("Appointment", "`Date` = '{$today}' AND `Time` BETWEEN '12:00:00' AND '23:59:59'");
return $appointments;
}Any pointers greatly appreciated.
| 300 Views | ||
|
Page:
1
|
Go to Top |

