我在代码中停留在日期函数上:
try(date_parse(min(MilestoneDate), '%Y-%m-%d %H:%i:%s')) > CURRENT_DATE
消息错误是:通用内部错误。我不知道这是什么意思 如果我注释掉'try(date_parse(min(MilestoneDate),'%Y-%m-%d%H:%i:%s'))> CURRENT_DATE',则整个代码都可以工作。但是我真的需要根据需求。我也尝试:具有DATE(SUBSTR(min(finishdate),1,10))> CURRENT_DATE。但是错误消息是:无法强制转换为最新日期。请帮忙。谢谢。
With ManagementView1 as (
select * from Management_View a
left join
(select *
from
(select projectobjectid, id as activity_id,finishdate as MilestoneDate, name as Milestone
from activity
where date = (select max(date) from activity)
union ALL
select projectobjectid, id as activity_id, min(finishdate) as finishdate,
name
from activity
where id in ('FS1000', 'PR1000', 'PR1500')
group by projectobjectid, id, name)
) b
ON try_cast(a.objectid as double) = b.projectobjectid
AND a.id = b.activity_id
)
select * from
(
select site, building, id, milestonetype, MilestoneDate, Milestone
from ManagementView1
WHERE milestonetype in ('Breakground', 'Energization')
UNION ALL
select site, building, id, milestonetype, min(MilestoneDate) as
MilestoneDate, Milestone
from ManagementView1
where milestonetype = 'PR'
having try(date_parse(min(MilestoneDate), '%Y-%m-%d %H:%i:%s')) >
CURRENT_DATE
--having DATE(SUBSTR(min(finishdate), 1, 10)) > CURRENT_DATE
-- and milestonetype = 'PR'
group by site, building, id, milestonetype, Milestone
) c
答案 0 :(得分:0)
我不认为try()
与date_parse()
一起使用-即使可以,也无法捕获所有错误。但是它应该与cast()
一起使用。因此,请尝试以下操作:
DATE(SUBSTR(MIN(finishdate), 1, 10))
MIN(TRY(CAST(SUBSTR(MilestoneDate, 1, 10) as date))) > CURRENT_DATE