data-dwh-dbt-project/models/reporting/general/dates.sql

43 lines
1.8 KiB
MySQL
Raw Normal View History

2024-10-02 10:11:48 +02:00
with dates as (select * from {{ ref("int_dates") }})
select
date_day as date_day,
prior_date_day as prior_date_day,
next_date_day as next_date_day,
prior_year_date_day as prior_year_date_day,
prior_year_over_year_date_day as prior_year_over_year_date_day,
day_of_week as day_of_week,
day_of_week_name as day_of_week_name,
day_of_week_name_short as day_of_week_name_short,
day_of_month as day_of_month,
day_of_year as day_of_year,
week_start_date as week_start_date,
week_end_date as week_end_date,
prior_year_week_start_date as prior_year_week_start_date,
prior_year_week_end_date as prior_year_week_end_date,
week_of_year as week_of_year,
iso_week_start_date as iso_week_start_date,
iso_week_end_date as iso_week_end_date,
prior_year_iso_week_start_date as prior_year_iso_week_start_date,
prior_year_iso_week_end_date as prior_year_iso_week_end_date,
iso_week_of_year as iso_week_of_year,
prior_year_week_of_year as prior_year_week_of_year,
prior_year_iso_week_of_year as prior_year_iso_week_of_year,
month_of_year as month_of_year,
month_name as month_name,
month_name_short as month_name_short,
lpad(month_of_year::text, 2, '0') || '-' || month_name as month_number_name,
lpad(month_of_year::text, 2, '0')
|| '-'
|| month_name_short as month_number_name_short,
month_start_date as month_start_date,
month_end_date as month_end_date,
prior_year_month_start_date as prior_year_month_start_date,
prior_year_month_end_date as prior_year_month_end_date,
quarter_of_year as quarter_of_year,
quarter_start_date as quarter_start_date,
quarter_end_date as quarter_end_date,
year_number as year_number,
year_start_date as year_start_date,
year_end_date as year_end_date
from dates