evibesmusic
asked on
How to compare DateTime between two Unix Timestamps in MySQL?
Experts,
Not sure why I am stumbling here so much but, I need to compare a DateTime field within my database to see if the dates stored in this column are between two user submitted Unix Timestamps.
Example (not working): SELECT * FROM registration WHERE checkin BETWEEN FROM_UNIXTIME('".$_POST['f rom']."') AND FROM_UNIXTIME('".$_POST['t o']."') AND `appointment`=1 AND `deleted` IS NULL ORDER BY checkin ASC;
When attempting to validate by printing my query to the screen, I get the following which seems correct: SELECT * FROM registration WHERE checkin BETWEEN FROM_UNIXTIME('15710112000 00') AND FROM_UNIXTIME('15716160000 00') AND `appointment`=1 AND `deleted` IS NULL ORDER BY checkin ASC;
I'm not receiving any syntax errors but, not sure I am employing the "FROM UNIXTIME()" function properly???
Cheers!
Not sure why I am stumbling here so much but, I need to compare a DateTime field within my database to see if the dates stored in this column are between two user submitted Unix Timestamps.
Example (not working): SELECT * FROM registration WHERE checkin BETWEEN FROM_UNIXTIME('".$_POST['f
When attempting to validate by printing my query to the screen, I get the following which seems correct: SELECT * FROM registration WHERE checkin BETWEEN FROM_UNIXTIME('15710112000
I'm not receiving any syntax errors but, not sure I am employing the "FROM UNIXTIME()" function properly???
Cheers!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you @noci.
ASKER
That seemed to do it. Interestingly enough, I'm employing HTML5 date selector inputs and the format you see my timestamps in is the format the date selector posts the data. I appreciate your help.
Cheers!