@@ -, +, @@ --------- -- expecting all happy results. -- note the removal of backticks and the assumed typecasting of a timestamp to date. -- specified opac_news.timestamp to make sure that it would more likely parse as a fieldname and not as a keyword. --- C4/NewsChannels.pm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) --- a/C4/NewsChannels.pm +++ a/C4/NewsChannels.pm @@ -188,27 +188,27 @@ sub get_opac_news { sub GetNewsToDisplay { my ($lang,$branch) = @_; my $dbh = C4::Context->dbh; - # SELECT *,DATE_FORMAT(timestamp, '%d/%m/%Y') AS newdate my $query = q{ - SELECT *,timestamp AS newdate + SELECT *,opac_news.timestamp AS newdate FROM opac_news WHERE ( expirationdate >= CURRENT_DATE() OR expirationdate IS NULL OR expirationdate = '00-00-0000' ) - AND DATE(timestamp) < DATE_ADD(CURDATE(), INTERVAL 1 DAY) + AND CAST( opac_news.timestamp AS DATE ) <= CURRENT_DATE() AND (lang = '' OR lang = ?) AND (branchcode IS NULL OR branchcode = ?) ORDER BY number }; # expirationdate field is NOT in ISO format? - # timestamp has HH:mm:ss, CURRENT_DATE generates 00:00:00 - # by adding 1, that captures today correctly. + # casting timestamp to date truncates HH:mm:ss + # changing to <= CURRENT_DATE() today is captured. my $sth = $dbh->prepare($query); $lang = $lang // q{}; $sth->execute($lang,$branch); my @results; while ( my $row = $sth->fetchrow_hashref ){ + # this will type cast and respect system preferences. $row->{newdate} = format_date($row->{newdate}); push @results, $row; } --