VFP
b1=1993/01/01
b2=1999/06/30
表1
a1,a2,a3
张三,1992/05/01,1999/02/28
李四,1997/01/01,2000/05/28
张三,1999/05/01,2009/12/30
如何找出在B1,B2时间段的人员
例如:
a1,a2,a3
张三,1993/01/01,1999/02/28
李四,1997/01/01,1999/06/30
张三,1999/05/01,1999/06/30
[解决办法]
*-- vfp9.0
Set Century On
Set Date YMD
Set Mark To '/'
Create Cursor 表1 (a1 C(10),a2 D,a3 D)
Insert Into 表1 Values ('张三',{^1992/05/01},{^1999/02/28})
Insert Into 表1 Values ('李四',{^1997/01/01},{^2000/05/28})
Insert Into 表1 Values ('张三',{^1999/05/01},{^2009/12/30})
Insert Into 表1 Values ('王五',{^1990/01/01},{})
Insert Into 表1 Values ('赵六',{},{^2000/05/02})
Insert Into 表1 Values ('于七',{},{})
Browse Title "原始数据"
*------------------------------------------
b1={^1999/05/01}
b2={^1999/06/30}
Select a1,Iif(Between(b1,a2,a3) Or Empty(a2),b1,a2) a2,Iif(Between(b2,a2,a3) Or Empty(a3),b2,a3) a3 From 表1 ;
Where ((b1 Between Evl(a2,{^0001/01/01}) And Evl(a3,{^9999/01/01})) Or (b2 Between Evl(a2,{^0001/01/01}) And Evl(a3,{^9999/01/01})) Or (b1<=Evl(a2,{^0001/01/01}) And b2>=Evl(a3,{^9999/01/01})))