Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
I need a way to subtract the difference between two dates and exprss the
difference in a format simular to 10 years 6 months 7 days. Assume a start date of 12/19/1943 and an end date of Today(). I have no trouble using datedif to get the number of years as 61 years, months as 11. I have now idea of how to convert the total number of days between the two dates to the correct number days. sngNumDays = DateDiff("d", DateOne, Now) gives the total number of days (22657). My current Code: Private Sub cmdAge_Click() Dim DateOne As Date Dim intYears As Integer Dim intMonths As Integer Dim sngNumDays As Single Dim introw As Integer For introw = 2 To 4 '3 different dates are entered on rows 2 through 4 DateOne = Cells(introw, 13).Value 'get the start date from the spreadsheet sngNumDays = DateDiff("d", DateOne, Now) 'total number of years in the period intYears = Int(sngNumDays / 365) intMonths = DateDiff("m", DateOne, Now) 'months is total months in the time period intMonths = intMonths - (intYears * 12) 'convert to months difference in the current year sngNumDays = DateDiff("d", DateOne, Now) 'total number of days in the period Me.Unprotect 'print the results to the row and column on the spread sheet Cells(introw, 14).Value = " " & intYears & " Years " & intMonths & " Months " & sngNumDays & " Days" Me.Protect Next End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Formula to find the working days difference between to dates? | Excel Discussion (Misc queries) | |||
Difference betn 2 Dates | Excel Discussion (Misc queries) | |||
difference between two dates in years, months and days. | Excel Worksheet Functions | |||
i NEED THE DIFFERENCE OF DATES DOWN TO YEARS...IE 11/1/02-4/16/85. | Excel Worksheet Functions | |||
How do I display months and years between two dates | Excel Discussion (Misc queries) |