输入banner图图片脚本导航/分类

sql 查询年龄

ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: wgx -- Create date: <Create Date, ,> -- Description: <Description, ,> -- ============================================= CREATE FUNCTION [dbo].Func_GetAge ( @birthday bigint ) RETURNS int AS BEGIN DECLARE @age int ; if(@birthday is null or LEN(@birthday)<8) begin set @age=0; end else begin set @age=FLOOR(datediff(DY, (LEFT(@birthday, 4) + - + SUBSTRING(CAST(@birthday AS varchar), 5, 2) + - + SUBSTRING(CAST(@birthday AS varchar), 7, 2) + 00:00:00), getdate()) / 365.25); end RETURN @age; END GO

dbo.Func_GetAge(19820212)

技术分享图片

sql 查询年龄

标签:@age   substr   int   class   com   arch   技术分享   ediff   day