I have 2 PHP variables formatted for DATETIME, but the column is in UNIX timestamp. How do I correctly do a BETWEEN on them?
$date_from
and $date_to
are in DATETIME format.
dateline
is stored as a UNIX timestamp.
The following isn't working:
if($date_from != "" && $date_to != "") {
$result_pag_num = mysql_query("SELECT COUNT(*) AS count FROM messages WHERE (folder = '$folder' AND username = '$username' AND FROM_UNIXTIME(dateline) BETWEEN '$date_from' AND '$date_to')");
} else {
$result_pag_num = mysql_query("SELECT COUNT(*) AS count FROM messages WHERE (folder = '$folder' AND username = '$username')");
}
Edit: all answers were good. I accepted the person who replied the fasted. The error was my own fault.