java,php,asp.net,linux,javascript,mysql,mssql,oracle,编程

根据身份证计算生日函数 sql

转载请注明:http://www.pmjava.com/Article/ShowInfo.asp?ID=56717
ALTER FUNCTION [dbo].[Birthday]
(
   
@IDCardNo NVARCHAR(50)
)
RETURNS DATETIME
AS
BEGIN
   
DECLARE @Birthday DATETIME

if (LEN(@IDCardNo)=15 or LEN(@IDCardNo)=16) and SUBSTRING(@IDCardNo,9,2) between 1 and 12   and SUBSTRING(@IDCardNo,11,2) between 1 and 31
SET @Birthday= CONVERT(VARCHAR(10),'19'+SUBSTRING(@IDCardNo,7,2)+'-'+SUBSTRING(@IDCardNo,9,2)+'-'+SUBSTRING(@IDCardNo,11,2),120)
else if LEN(@IDCardNo)=18 and SUBSTRING(@IDCardNo,7,2)>=19 and SUBSTRING(@IDCardNo,11,2) between 1 and 12   and SUBSTRING(@IDCardNo,13,2) between 1 and 31
SET @Birthday= CONVERT(VARCHAR(10),SUBSTRING(@IDCardNo,7,4)+'-'+SUBSTRING(@IDCardNo,11,2)+'-'+SUBSTRING(@IDCardNo,13,2),120)
else
SET @Birthday=null
RETURN(@Birthday)
END

                                                                  

posted on 2009-06-12 18:21 rrong_m 阅读(496) 评论(0)  编辑  收藏

<2009年6月>
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011

导航

统计

常用链接

随笔档案

文章分类

文章档案

java编程

搜索

积分与排名

最新评论

阅读排行榜

评论排行榜