|
SET @d0 = "2000-01-01";
SET @d1 = "2020-12-31";
SET @str = "Q";
SET @date = date_sub(@d0, interval 1 day);
INSERT INTO dim_time
SELECT @date := date_add(@date, interval 1 day),
year(@date),
month(@date),
DAYOFYEAR(@date),
day(@date) as d,
weekday(@date)+1 as wd,
week(@date, 3) as w,
dayname(@date) as wd_name,
monthname(@date) as m_name,
quarter(@date) as q,
CONCAT(@str,quarter(@date)) as qq,
DAYOFMONTH(last_day(@date)),
date_format(@date, "%Y%m%d"),
date_format(@date, '%d-%m-%Y')as yw
FROM test_date
WHERE date_add(@date, interval 1 day) |
|
|