早教吧 育儿知识 作业答案 考试题库 百科 知识分享

db2判断一个日期在给定时间中如chardate(varchar)201108;expdate(varchar)2008-10-100:00:00impdate(varchar)2018-10-3100:00:00.我是这样写的,但报错了date(b.chardate)betweensubstr(c.expdate,1,7)andsubstr(c.impdate,

题目详情
db2 判断一个日期在给定时间中
如 char_date(varchar) 201108 ;exp_date(varchar) 2008-10-1 00:00:00 imp_date(varchar) 2018-10-31 00:00:00.我是这样写的,但报错了
date(b.char_date) between substr(c.exp_date,1,7) and substr(c.imp_date,1,7) ;
“date(b.char_date)”存在错误“DB2 SQL Error:SQLCODE=-180,SQLSTATE=22007,SQLERRMC=null,DRIVER=3.57.82”
初次接触db2,
▼优质解答
答案和解析
你这语句有问题
应该这样查
select b.char_date
from b,c
where b.char_date between c.exp_date and c.imp_date
而且c.exp_date ,c.imp_date字段还要确定一个日期值才来做范围