[RSS Feed/News] Small SQL question: Getting posts after certain date

Status
Not open for further replies.

XenForo

Administrative
  • Thread starter
  • Admin
  • #1
I've been using this query for years to get the number of posts made by myself in the past 365 days. It works great:

Code:

Code:
    $res = $db->query('
    SELECT COUNT(*) AS total
    FROM xf_post AS post
    WHERE user_id = 1
    AND (post.post_date >= UNIX_TIMESTAMP(CURDATE() - INTERVAL 8760 HOUR))
        ');
    $num_rows = $res->fetchColumn();
    echo $num_rows;

However I want to know how many posts were made in THIS year, so I modified the code to:

Code:

$res =...

Read more

ادامه مطلب...
 
Status
Not open for further replies.
Back
Top Bottom