0

I am working on a project where admin can book an building unit for a customer.And i require that a month lie between two dates of booking or not for calendar.I am using query for this is

"SELECT * FROM rt_booking WHERE rt_unit_id='".$urow['rt_unit_id']."' AND rt_start_date<=".$date11." AND rt_end_date<=".$date22;

Here rt_start_date(unixtimestamp) and rt_end_date(unixtimestamp) is the booking start and end dates.and date11(unixtimestamp) and date22(unixtimestamp) is month starting date and month ending date for a caledar month.
It is working well if the booking start date(rt_start_date) is less more than one month with starting month date(date11) and booking ending date is greater than month ending date.
But if booking date is from 15 january 2012 to 20 january 2012 then it should be selected with for month 'january' from date11=strtotime(01-01-2012) and month end strtotime(31-01-2012);

Edited by diafol: fixed formatting

2
Contributors
4
Replies
12
Views
4 Years
Discussion Span
Last Post by daniel36
1

months are the trickiest of all comparisons!

Use the YEAR_MONTH function. Like:

SELECT EXTRACT(YEAR_MONTH FROM (FROM_UNIXTIME(1360926503, '%Y-%m-%d')))

This will get '201302' for today's date.

Edited by diafol

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.