Hello Mod, and anyone, I'm building a Human resources app. for my project. In an employee form i have a problem for knowing the employee age. User input the date of birth of the employee and the program calculate the employee age to the present. I don't know the syntax in vb to compare a date to another, and how to subtract the date of birth from present date. Thank You and God Bless Us.

DateDiff function will do that for. you

Yes, DateDiff() function will find the Difference between two Dates or two Times.

Syntax
Function DateDiff( Interval As String, Date1 As Date, Date2 As Date)

Interval may be
d -Day, y -Day of year, h -Hour, n -Minute, m -Month, s -Second, w -weekday, ww - week, yyyy -Year

Example

Dim TheDate As Date   
  Dim Msg
  
  TheDate = InputBox("Enter a date")
  Msg = "Days from today: " & DateDiff("d",   Now, TheDate)
  MsgBox Msg
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.