用日期作为查询条件:
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add('select distinct b.Bwid 办文序号,b.Lwid 来文序号,a.Lwdw 来文单位,'
+ 'a.Lwbt 来文标题,b.Zbcs 主办处室,c.name 主办人'
+ ' from oadbo.bw_lwdjb a,oadbo.bw_bwdjb b,oadbo.oc_dlgl c'
+ ' where a.Lwid = b.Lwid and b.Zbcs = ' + IntToStr(g_tsUserInfo.nCsId)
+ ' and b.bwlx = 20 and (a.lwzt = 50 or a.lwzt = 40) and b.bwzt = 30'
+ ' and qssj >= "' + datetostr(time1.Date) + '" '
+ ' and qssj <= "' + datetostr(time2.Date) + '" and b.zbr=c.bsname' );
Query1.Open;
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add('select distinct b.Bwid 办文序号,b.Lwid 来文序号,a.Lwdw 来文单位,'
+ 'a.Lwbt 来文标题,b.Zbcs 主办处室,c.name 主办人'
+ ' from oadbo.bw_lwdjb a,oadbo.bw_bwdjb b,oadbo.oc_dlgl c'
+ ' where a.Lwid = b.Lwid and b.Zbcs = ' + IntToStr(g_tsUserInfo.nCsId)
+ ' and b.bwlx = 20 and (a.lwzt = 50 or a.lwzt = 40) and b.bwzt = 30'
+ ' and qssj >= "' + datetostr(time1.Date) + '" '
+ ' and qssj <= "' + datetostr(time2.Date) + '" and b.zbr=c.bsname' );
Query1.Open;
showmessage(inttostr(query.recordcount));