views:

72

answers:

1

With Coldfuson & MySQL - How to update the query to check for new entries that have a timestamp that occurs in the last 24 hours?

Query:

<cfquery name="caller.sel_BlogEntries" datasource="#request.db#">
SELECT      blogentry.dateAdded, person.personName
FROM        blogentry INNER JOIN person ON blogentry.personID = person.personID
WHERE       blogentry.deleted = 'N'
ORDER BY    blogentry.dateAdded DESC
</cfquery>

blogentry.dateAdded is a MySql TimeStamp

Thanks

+3  A: 
WHERE ... 
  AND DATE_ADD(blogentry.dateAdded, INTERVAL 1 DAY) >= NOW()
Ignacio Vazquez-Abrams
Though that does work, using date functions on a column can sometimes interfere with indexes. A better alternative might be>: WHERE blogentry.dateAdded >= DATE_ADD(NOW(), INTERVAL -1 DAY) ...
Leigh