We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,371 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

use unixtimestamp in mysql query.

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
19 Hours
Discussion Span
3 Months Ago
Last Updated
16
Views
Question
Answered
daniel36
Junior Poster
188 posts since Nov 2011
Reputation Points: 5
Solved Threads: 3
Skill Endorsements: 0

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.")";
broj1
Nearly a Posting Virtuoso
1,212 posts since Jan 2011
Reputation Points: 167
Solved Threads: 164
Skill Endorsements: 13

thank you broj1.it is working.

daniel36
Junior Poster
188 posts since Nov 2011
Reputation Points: 5
Solved Threads: 3
Skill Endorsements: 0
Question Answered as of 3 Months Ago by broj1

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0766 seconds using 2.66MB