'calculate Daily Active Users from a week ago and a month ago

How do I find daily active users (DAU)for a week ago, and a month ago? The following query gives me the number of users who were last active 7 days ago and 31 then days ago, but not how many people were active 7 days ago and 31 days ago.

select

sum(case when (lastactivetimestamp::date = current_date - 7) then 1.0 else 0.0 end) DAU_week_ago,
sum(case when (lastactivetimestamp::date = current_date - 31) then 1.0 else 0.0 end) DAU_month_ago

from customers

I am working with a table called 'customers'

customers
id
timestampregistered
lastactivetimestamp


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source