很抱歉另一个与日期有关的问题,但我找不到解决此问题的帖子。 我正在尝试在日期表中添加一列,以显示每个月的天数,并对have年进行处理-以下是我的进度:
case when
Date like '01%' then '31'
Date like '02%' and then ''
Date like '03%' then '31'
Date like '04%' then '30'
Date like '05%' then '31'
Date like '06%' then '30'
Date like '07%' then '31'
Date like '08%' then '31'
Date like '09%' then '30'
Date like '10%' then '31'
Date like '11%' then '30'
Date like '12%' then '31'
end as DAYS_IN_MONTH
答案 0 :(得分:1)
如果您有日期,则可以使用:
fun View.getBackgroundColor() = (background as? ColorDrawable?)?.color ?: Color.TRANSPARENT
答案 1 :(得分:0)
-生成带有日期的系列
with base_table as
(
select
dateadd(day, '-' || seq4(), current_date()) as dte
from
table
(generator(rowcount => 1095))
)
-计算分组后每月的天数
SELECT count(*) as days_in_month,
date_trunc('Month',dte) as month
FROM base_table
-- Filter here for necessary days
where dte between '2019-01-01' and '2019-12-31'
GROUP BY 2
-将此表与您的表连接起来