0
我想比较一个日期时间从SQL和今天的日期。 sql中的datetime例如是2015/05/09 12:00:00,当前日期是2015/05/09。我想比较这些东西,如果它们是平等的,但是整整一天,所以时间是一个问题。我有以下查询。比较日期和日期时间
$q1="SELECT reservations.reservation_id, reservations.room_id, room.room_rate, reservations.arrival_date, reservations.departure_date,
meals.meal_rate, room.room_rate, roomtype.max_persons,
CONCAT(clients.first_name,' ',clients.last_name)as name
FROM reservations, clients, meals, room, roomtype
WHERE reservations.room_id=room.room_id AND reservations.client_id=clients.client_id AND room.roomtype_id=roomtype.roomtype_id
AND reservations.meals=meals.meal_id AND reservations.arrival_date=CURDATE()
GROUP BY reservation_id
";
reservations.arrival_date = CURDATE()这只在12:00:00点时相等。我希望这是相等的一整天。实际上,我想比较,如果这两个日期是相等的没有时间,但我的数据库必须是与日期时间... 有没有人有想法? thanx
实际上这是一个旧的php代码,我想添加something.now我使用join.thnx无论如何。 你的第二个解决方案也适用,但我只是认为更简单$ today = date(“Y-m-d 12:00:00”);然后比较到期日与今天! – stavros
@stavros。 。 。如果您始终知道时间组件恰好是中午,那么这将起作用。 –