CodeWidgets.com: Online Source Code Library: C#, ASP, ASP.NET, VB, VB.NET, VB Script, Microsoft Access, Excel, JavaScript, J Script, XML, VBScript, Website Design, DevExpress Components, Reporting, Application and Website Templates.

Widget #CS0043

Age Function VB.Net using DateDiff()

Free

Public Function Age(ByVal Birthdate As System.DateTime) As Long
Try
Dim CurrentDate As System.DateTime = System.DateTime.Today
Select Case Month(Birthdate)
    Case Is < Month(System.DateTime.Today)
        Age = DateDiff("YYYY", Birthdate, Now())
    Case Is = Month(CurrentDate)
         Select Case Day(Birthdate)
             Case Is < Day(CurrentDate)
                Age = DateDiff("YYYY", Birthdate, Now())
             Case Is = Day(CurrentDate)
                Age = DateDiff("YYYY", Birthdate, Now())
             Case Is > Day(CurrentDate)
                  Age = DateDiff("YYYY", Birthdate, Now()) - 1
         End Select
    Case Is > Month(CurrentDate)
        Age = DateDiff("YYYY", Birthdate, Now()) - 1
    Case Else
        Age = 0
End Select
Catch ex As System.Exception
    'Error handling code does here
End Try
End Function

Last Updated: 4/27/2018


Related Widgets 
Price 
# 
CS0167 Client Side Javascript Calendar/DatePicker (ASP.NET, C#.Net)$20.00Add To Cart
CS0166 Client Side Javascript Calendar/DatePicker (ASP.NET, VB.Net)$20.00Add To Cart

Recently Viewed Widgets 
Price 
# 
No data to display

Collapse/Expand
Format

Download

Online Purchase And Pickup


Collapse/Expand
License

License

Developer Re-Use: Programming Experience Required

Project Development Use Only. Re-Distribution Permitted only as part of a compiled Application. This source code is provided to you "as is" without warranty.
CLICK HERE FOR TERMS OF USE
Copyright 2000-2018 CodeWidgets.com/Comrie Software Solutions


This website uses Cookies to store User information and Shopping Cart Items for the duration of your visit to CodeWidgets.com.

No Credit Card or Financial information is stored by CodeWidgets.com. Click Here For Our Complete Privacy Policy and Terms of Use.

I Understand