直接在单元格中写公式:
判断日期:if(sql("JDBC1","select FBC from TEST where order by FDATE desc,FBC desc",1,1)="16:00-24:00",datedelta(sql("JDBC1","select CONVERT(VARCHAR(10),FDATE,120) from TEST order by FDATE desc",1,1),1),sql("JDBC1","select CONVERT(VARCHAR(10),FDATE,120) from TEST order by FDATE desc",1,1))
判断时间:if(sql("JDBC1","select count(FBC) from TEST where CONVERT(VARCHAR(10),FDATE,120)= '"+B4+"' ",1,1)=0,"00:00-08:00",if(sql("JDBC1","select FBC from TEST where CONVERT(VARCHAR(10),FDATE,120)= '"+B4+"' order by FBC desc",1,1)="00:00-08:00","08:00-16:00","16:00-24:00"))