declare @card varchar(20)
set @card = '你的身份证'
IF len(@card)=15
begin
select sex=case convert(int,right(rtrim(@card),1))%2
when 0 then '女'
else '男' end
end
else if len(@card)=18
select sex=case convert(int,substring(@card,17,1))%2
when 0 then '女'
else '男' end
[Quote=引用 1 楼 sy_binbin 的回复:]
<%
a = "身份证号码"
if len(a) = 15 then
lastNO = right(a,left(len(a)-1,1))
elseif len(a) = 18 then
lastNO = left(right(a,2),1)
end if
if lastNO mod 2 = 0 then
response.Write "女"
else
response.Write "男"
end if
%>
[/Quote]
<%
a = "身份证号码"
if len(a) = 15 then
lastNO = right(a,left(len(a)-1,1))
elseif len(a) = 18 then
lastNO = left(right(a,2),1)
end if
if lastNO mod 2 = 0 then
response.Write "女"
else
response.Write "男"
end if
%>