I want to count all the rows in a table where groop is = '2' and the encounter_date I've stored is less than one month old.
I have a table column called: encounter_date
Date format = YYYY-MM-DD
I prefer a solution that could use that format although I'm open to changing to Unix time if I have to.
Based on this strtotime example below, I'll have to switch to Unix time, but would prefer to not.
Anyways, I could really use some help with this if anyone knows how to do this.
Code: Select all
$query = "SELECT encounter_date FROM crisis WHERE groop = '2' ";
$result = mysqli_query($con, $query) or die (mysqli_error($con));
while ($row = mysqli_fetch_object($result)) {
$encounter_date = $row->encounter_date;
if(strtotime($encounter_date) < strtotime('1 month ago')) {
$count = mysqli_num_rows($result);
}
}
echo $count;