2 个解决方案
#1
select floor(sysdate - KSS_RFPERSON_USER.BIRTH_D) days, KSS_RFPERSON_USER.* from KSS_RFPERSON_USER where days between 18*365 and 25*365
将sysdate和你的日期字段格式一致
将sysdate和你的日期字段格式一致
#2
楼上的不够精确
select * from KSS_RFPERSON_USER
where
to_date(to_char(sysdate,'YYYY')-25||to_char(sysdate,'MMDD'),'YYYYMMDD')-birth_d<0
and
to_date(to_char(sysdate,'YYYY')-18||to_char(sysdate,'MMDD'),'YYYYMMDD')-birth_d>0
也就是说
今天是2004-08-16,那么1979-08-15就不算是25岁了
select * from KSS_RFPERSON_USER
where
to_date(to_char(sysdate,'YYYY')-25||to_char(sysdate,'MMDD'),'YYYYMMDD')-birth_d<0
and
to_date(to_char(sysdate,'YYYY')-18||to_char(sysdate,'MMDD'),'YYYYMMDD')-birth_d>0
也就是说
今天是2004-08-16,那么1979-08-15就不算是25岁了
#1
select floor(sysdate - KSS_RFPERSON_USER.BIRTH_D) days, KSS_RFPERSON_USER.* from KSS_RFPERSON_USER where days between 18*365 and 25*365
将sysdate和你的日期字段格式一致
将sysdate和你的日期字段格式一致
#2
楼上的不够精确
select * from KSS_RFPERSON_USER
where
to_date(to_char(sysdate,'YYYY')-25||to_char(sysdate,'MMDD'),'YYYYMMDD')-birth_d<0
and
to_date(to_char(sysdate,'YYYY')-18||to_char(sysdate,'MMDD'),'YYYYMMDD')-birth_d>0
也就是说
今天是2004-08-16,那么1979-08-15就不算是25岁了
select * from KSS_RFPERSON_USER
where
to_date(to_char(sysdate,'YYYY')-25||to_char(sysdate,'MMDD'),'YYYYMMDD')-birth_d<0
and
to_date(to_char(sysdate,'YYYY')-18||to_char(sysdate,'MMDD'),'YYYYMMDD')-birth_d>0
也就是说
今天是2004-08-16,那么1979-08-15就不算是25岁了