0

i want to compare dates stored in database in the format yyyy-mm-dd by changing it in unixtimestamp in the mysql query.for this my query is

$bquery="SELECT * FROM rt_booking WHERE rt_unit_id='".$_POST['unit_id']."' AND (SELECT UNIX_TIMESTAMP(str_to_date(rt_start_date,'%Y-%m-%d'))>=".$my11." OR SELECT UNIX_TIMESTAMP(str_to_date(rt_end_date,'%Y-%m-%d'))<=".$my22.")";

but it is giving syntax error.

2
Contributors
2
Replies
16
Views
4 Years
Discussion Span
Last Post by daniel36
Featured Replies
  • 2

    Are you sure the second and third SELECT keywords have to be there. Would this be OK: $bquery="SELECT * FROM rt_booking WHERE rt_unit_id='".$_POST['unit_id']."' AND (UNIX_TIMESTAMP(str_to_date(rt_start_date,'%Y-%m-%d'))>=".$my11." OR UNIX_TIMESTAMP(str_to_date(rt_end_date,'%Y-%m-%d'))<=".$my22.")"; Read More

2

Are you sure the second and third SELECT keywords have to be there. Would this be OK:

$bquery="SELECT * FROM rt_booking WHERE rt_unit_id='".$_POST['unit_id']."' 
AND (UNIX_TIMESTAMP(str_to_date(rt_start_date,'%Y-%m-%d'))>=".$my11." 
OR UNIX_TIMESTAMP(str_to_date(rt_end_date,'%Y-%m-%d'))<=".$my22.")";
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.