Y-X-DONG
CREATE Function Dbo.GetAge
(
@birthday datetime,
@now datetime
)
Returns int
As
Begin
Declare @Age int, @year int, @month int, @Day int
Set @age = 0
Set @year = 0
Set @month = 0
Set @day = 0
Set @year = DatePart(Year,@Now) - DatePart(Year, @BirthDay)
Set @month = DatePart(Month,@Now) - DatePart(Month, @BirthDay)
Set @Day = DatePart(Day,@Now) - DatePart(Day, @BirthDay)
if( @month > 0)
Set @Age = @Year
if( @month < 0)
Set @Age = @Year - 1
if(@month = 0)
Begin
if( @Day >= 0)
Set @Age = @Year
Else
Set @Age = @Year -1
End
Return(@Age)
End

 

 

分类:

技术点:

相关文章:

  • 2021-11-30
  • 2022-02-22
  • 2022-12-23
  • 2022-02-14
  • 2022-03-03
  • 2021-11-04
猜你喜欢
  • 2022-12-23
  • 2021-12-19
  • 2022-12-23
  • 2022-12-23
  • 2021-05-20
  • 2021-12-25
相关资源
相似解决方案