Forums

WHERE after a date

ash6851 22 May, 2014
I have a database table storing announcements. The table has a datetime column called "created", and I'd like to only show announcements that were entered within the last 7 days (in my chronoconnectivity connection). It seems that the where clause just filters everything out. Anyone know how I'm supposed to do this?

I tried the following code (in the Model conditions section):
<?php
$oneWeekAgo = strtotime("-1 week");
$now = strtotime("now");

return array(":announcements.created between $oneWeekAgo and $now");
?>


I have the debug section enabled, and the where clause of my query shows up like this:
"WHERE announcements.created between 1400636096 and 1400722496"
Max_admin 22 May, 2014
You will need to format the date info you enter to be in the same db date format:

$oneWeekAgo = date("Y-m-d H:i:s", strtotime("-1 week"));
$now = date("Y-m-d H:i:s", strtotime("now"));


Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.