1.11M Members

use unixtimestamp in mysql query.

 
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
 

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.")";
 
0
 

thank you broj1.it is working.

Question Answered as of 1 Year Ago by broj1
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article