Hello Friends
I need to find out the difference between two dates
the one i know is datediff but it gives me either No of days or year
i want it to be in this fashion
days/Months/Year
in date format
:wave:
Printable View
Hello Friends
I need to find out the difference between two dates
the one i know is datediff but it gives me either No of days or year
i want it to be in this fashion
days/Months/Year
in date format
:wave:
VB Code:
Dim IYourAgeInDays As Long 'First you need to see if a valid date is entered. If IsDate(Text1.Text) Then whatevervariable = CDate(Text1.Text) 'then use DateDiff lYourAgeInDays = DateDiff("d", whatevervariable, Now) 'd = days lblAgeDays.Caption = CStr(lYourAgeInDays) 'put on label s = seconds yyyy = years m = months Else MsgBox "Error" End If
Hope it helps!
It has given me the number of days but then to calculate it to years Month days was the Question
Instead of: DateDiff("d", whatevervariable, Now) 'd = daysQuote:
Originally Posted by vbcoder2
Use DateDiff("m", whatevervariable2, Now) 'm = Months
and DateDiff("yyyy", whatevervariable3, Now) 'yyyy = years
Hello
This should also get the answer in the format of dd/mm/yy. Hope its what ur after.
VB Code:
Text1.Text = Format(DateDiff("d", "1/2/02", "1/2/03", vbSunday, vbFirstJan1), "dd/mm/yy", vbSunday, vbFirstJan1)