zoukankan      html  css  js  c++  java
  • sql 查询年龄

    SET 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)

  • 相关阅读:
    JSON
    vue中跳转页面逻辑
    生命周期的几个阶段
    vue学习大纲
    Vue留言 checked框案列
    Vue内容
    linux -- iptables
    linux --- DNS
    linux --- samba
    linux --- vsftp
  • 原文地址:https://www.cnblogs.com/wgx0428/p/10172314.html
Copyright © 2011-2022 走看看