Reputation: 1799
I am trying to fetch data from the current week and not from the last 7 days. My query is:
select
order_datetime_tz::date AS date,
orders
FROM
order_fact f
where order_datetime_tz < current_date
and order_datetime_tz >= date_trunc('week',current_date) - interval '1 week'
However this returns me the last 7 days.. Any idea on that?
Thanks!!
Upvotes: 1
Views: 2191
Reputation: 782
The beginning of the current week is date_trunc('week',current_date)
, so you just want to query dates later later than that:
select
order_datetime_tz::date AS date,
orders
FROM
order_fact f
where order_datetime_tz >= date_trunc('week',current_date)
Upvotes: 6