Forum Discussion

Inactive User's avatar
Inactive User
8 years ago

posts count of last 7 days

Hello everybody! I'm trying to write a custom component to get the count of threads posted within the last 7 days or so using APIv2. Here's what i did! <#assign today = .now?long /> <#assign minus...
  • luk's avatar
    8 years ago

    This should work as well

     

    <#assign now = datesupport.now />
    <#assign today = now.millisecondsAsString?number?number_to_datetime?iso("Europe/Zurich") />
    <#assign lastWeek = now.addWeek(-1).millisecondsAsString?number?number_to_datetime?iso("Europe/Zurich") />
    <#assign query = "SELECT count(*) FROM messages WHERE post_time > " + lastWeek + " AND post_time < " + today + "ORDER BY post_time ASC" />
    <#assign data = rest("2.0", query) />