Skip to content

Commit

Permalink
fix: cleanup time intervals
Browse files Browse the repository at this point in the history
  • Loading branch information
ccerv1 authored and wcchang1115 committed May 20, 2024
1 parent 29254a0 commit 98e77cf
Showing 1 changed file with 29 additions and 18 deletions.
47 changes: 29 additions & 18 deletions warehouse/dbt/models/intermediate/events/int_time_intervals.sql
Original file line number Diff line number Diff line change
@@ -1,19 +1,30 @@
with dates as (
select
'7 DAYS' as time_interval,
DATE_SUB(CURRENT_DATE(), interval 7 day) as start_date
union all
select
'30 DAYS' as time_interval,
DATE_SUB(CURRENT_DATE(), interval 30 day) as start_date
union all
select
'90 DAYS' as time_interval,
DATE_SUB(CURRENT_DATE(), interval 90 day) as start_date
union all
select
'6 MONTHS' as time_interval,
DATE_SUB(CURRENT_DATE(), interval 6 month) as start_date
union all
select
'1 YEAR' as time_interval,
DATE_SUB(CURRENT_DATE(), interval 1 year) as start_date
union all
select
'ALL' as time_interval,
DATE('1970-01-01') as start_date
)

select
'30D' as time_interval,
DATE_SUB(CURRENT_DATE(), interval 30 day) as start_date
union all
select
'90D' as time_interval,
DATE_SUB(CURRENT_DATE(), interval 90 day) as start_date
union all
select
'6M' as time_interval,
DATE_SUB(CURRENT_DATE(), interval 6 month) as start_date
union all
select
'1Y' as time_interval,
DATE_SUB(CURRENT_DATE(), interval 1 year) as start_date
union all
select
'ALL' as time_interval,
DATE('1970-01-01') as start_date
dates.time_interval,
TIMESTAMP(dates.start_date) as start_date
from dates

0 comments on commit 98e77cf

Please sign in to comment.