YearCode:=yearof(Date);
MonthCode:=monthof(Date);
if MonthCode>9 then
FTime1:=inttostr(YearCode)+inttostr(MonthCode)
else
FTime1:=inttostr(YearCode)+'0'+inttostr(MonthCode);
FTime:= DateTimeToStr(Date); //
//FTime1:=formatdatetime('yyyymm',Date);
//FTime1:=leftstr(FTime,6);
TimeTemp:=formatdatetime('yyyy-mm',Date);
cds.Active:=false;
cds.CommandText:='select /*+index(a,TAB1_I)*/ max(a.id) as id from TAB1 a where '
+'INSTR(a.id,'''+FTime1+''', 1,1 )>0 and length(a.id)=11 and a.UPDATE_TIME between '
+' to_date('''+TimeTemp+'-01 00:00:00'',''yyyy-mm-dd hh24:mi:ss'') '
+' and to_date('''+FTime+''',''yyyy-mm-dd hh24:mi:ss'') ' ;
cds.Active:=true;
月份处理及SQL时间条件instr函数
最新推荐文章于 2022-12-05 17:14:50 发布