MYSQL min() Function

The min() function in a mysql query will get the lowest desired value for a given field. The example below will obtain the oldest date between '2012-01-02' and now.

<?php
include('connect.inc');
$db = public_db_connect();
public_db_connect();

$command = "SELECT min(date) as date FROM table_sort WHERE date < now() AND date > '2012-01-01' ";
$result = mysqli_query($db, $command);

while ($row = mysqli_fetch_assoc($result)) {
    $date = $row['date'];
    echo $date;
}