Micro Focus QTP (UFT) Forums

Full Version: Date Functions
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have any birth date. For example 04/07/1973 I would like to take the current date - any birth date and get the person's current age. Is there a function I can use? For example 07/29/2008 - 04/07/1973 = 35
Thanks,
Anna
Check this , i hope it's usefull for u

Code:
strBirthDate="10/10/2000"
vmonth = dateDiff("m",strBirthDate, date())
vday= datediff("d", strBirthDate, date())
If month(Now()) > month(strBirthDate)  OR month(Now()) = month(strBirthDate) Then
     If day(strBirthDate) = day(Now()) OR Day(Now()) > day(strBirthDate)Then
          vyear = DateDiff("y", year(strBirthDate), year(Now()))
    else
        vyear = DateDiff("y", year(strBirthDate), year(Now())) - 1    
    end if
    
else
       vyear = DateDiff("y", year(strBirthDate), year(Now())) - 1
End If

msgbox "Year::"& vyear
Hi,
This seems to work well. Thank you!