create table TT ( name varchar(10), Sex int, birthday DateTime ) go insert into TT values('Marky','0','1947-08-01') insert into TT values('Lily','1','1950-08-01') insert into TT values('John','0','1951-08-01') insert into TT values('Lucy','1','1960-08-01') select * from TT where (DATEDIFF(day, birthday, getdate())>(60*365) and sex=0) or (DATEDIFF(day, birthday, getdate())>(55*365) and sex=1) drop table TT
select * from TT where (DATEDIFF(day,getdate(),DATEADD(year, 60, birthday))> 3 and sex=0) or (DATEDIFF(day,getdate(),DATEADD(year, 55, birthday))> 3 and sex=1)
create table TT ( name varchar(10), Sex int, birthday DateTime ) go insert into TT values('Marky','0','1947-08-01') insert into TT values('Lily','1','1950-08-01') insert into TT values('John','0','1951-08-01') insert into TT values('Lucy','1','1960-08-01') select * from TT where (DATEDIFF(month, birthday, getdate())> ((60*12)-3) and sex=0) or (DATEDIFF(month, birthday, getdate())> ((55*12)-3) and sex=1) drop table TT
(
name varchar(10),
Sex int,
birthday DateTime
)
go
insert into TT values('Marky','0','1947-08-01')
insert into TT values('Lily','1','1950-08-01')
insert into TT values('John','0','1951-08-01')
insert into TT values('Lucy','1','1960-08-01') select * from TT
where (DATEDIFF(day, birthday, getdate())>(60*365) and sex=0)
or (DATEDIFF(day, birthday, getdate())>(55*365) and sex=1)
drop table TT
where (DATEDIFF(day,getdate(),DATEADD(year, 60, birthday))> 3 and sex=0)
or (DATEDIFF(day,getdate(),DATEADD(year, 55, birthday))> 3 and sex=1)
create table TT
(
name varchar(10),
Sex int,
birthday DateTime
)
go
insert into TT values('Marky','0','1947-08-01')
insert into TT values('Lily','1','1950-08-01')
insert into TT values('John','0','1951-08-01')
insert into TT values('Lucy','1','1960-08-01') select * from TT
where (DATEDIFF(month, birthday, getdate())> ((60*12)-3) and sex=0)
or (DATEDIFF(month, birthday, getdate())> ((55*12)-3) and sex=1)
drop table TT