CodeWidgets.com Online Source Code Library -ASP, ASP.NET, VB, VB.Net, Microsoft® Access, Javascript, VBScript, Website Design, Web Applications, Custom Programming Services Available.

 CodeWidgets.com ASP, ASP.NET, VB, VB.Net,
Microsoft® Access, Javascript, VBScript,
Website Design, Web Applications
Shopping Cart (0) Items $0.00      
 CodeWidgets.com
CodeWidgets.com

 

Website Stats to Date

Pages Viewed 4,401,732
Visitors 1,206,536
Widgets Viewed 3,009,755
Since January 1/2003
 
 
Active Users: 17
 

 
PayPal: Secure online payments!
 
Widget #CS0043

Age Function VB.Net using DateDiff()

Age Function VB.Net using DateDiff()
Click Here for Demo!

Send Link

Questions

Currency Conv.
  Widget Info  
Asp.Net, VB.Net
Enter birthdate, returns age in years.
Not applicable to infants under 1 year where age is measured in weeks or months

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
 Licensing
Format: Download
Online Purchase And Pickup
Licencing Terms: 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 2002-2006 Comrie Software Solutions
 Related Widgets

Add Sounds to button events. ASP.NET
Age Function VB 6.0 Using DateDiff()
ProperCase.Net Function
WebStore - Online Store Application Template (ASP.NET)

ShoppingCart Empty
Services Contact Info Legal Info
Designated trademarks and brand names are the property of their respective owners.

By accessing this website it is assumed that you agree to the TERMS OF USE.

Send questions or comments regarding this website to  Comrie Software Solutions.

Click here for a complete list of available Widgets.