Sharepoint - End date minus Start date = Years? - sharepoint

I am needing to calculate the number of years between two fields;
Field A
Start Date (dd/mm/yyyy)
Field B
End Date (dd/mm/yyyy)
Field C
Calc formula display difference between Field A and B in years and months i.e 5.2
Thanks all.

Assuming you are asking about Calculated Columns then you need the DATEDIF function
Also I am assuming that the 5.2 is 5 years and 2 months - not 5 years and .2 of a year - be a bit more specific in your question and you will get better answers.
So
= DATEDIF([Start Date],[End Date],"Y")
& " years and " &
DATEDIF([Start Date],[End Date],"YM")
& " months "
Examples of common formulas

Related

Comparing dates in Excel

I'm trying to compare date in excel to return a value.
I want to see...
if date of birth + today() is less than DATE(2021,9,1) years then output 6
if date of birth + today() is less than DATE(2021,9,1) years then output 5
if date of birth + today() is less than DATE(2021,9,1) years then output 4
if date of birth + today() is less than DATE(2021,9,1) years then output 3
This is for a school project. I'm struggling to understand the date concept.
Can someone point me in the right direction?
Thanx for reading,
Sam
This should work, imagining that cell A1 contains the date of birth:
=IF((A1 + today()) < DATE(2021,9,1), 6)
=IF((A1 + today()) < DATE(2021,9,1), 5)
=IF((A1 + today()) < DATE(2021,9,1), 4)
=IF((A1 + today()) < DATE(2021,9,1), 3)
After going home and sleeping on it, I think I figured it out. I wanted my date to be static and check against pupil date of births to determine their age for a particular year. I already have a version of this which is dynamic and updates itself when the sheet is loaded. Here is what I did, where E3 is equal to a pupils date of birth...
=IF(E3="","",
IF(DATEDIF(E3,DATE(2021,9,1),"Y")+1>=11,6,
IF(DATEDIF(E3,DATE(2021,9,1),"Y")+1>=10,5,
IF(DATEDIF(E3,DATE(2021,9,1),"Y")+1>=9,4,
IF(DATEDIF(E3,DATE(2021,9,1),"Y")+1>=8,3,
"")))))
If there is an easier way to accomplish this I would relish feedback.
Thanx again to those of you who replied,
Sam
This is my dynamic version
=IF(E3="","",MAX(0,DATEDIF(DATE(YEAR(E3+122),9,1),NOW(),"Y" )-4))
This calculates age
=IF(E3="","",
DATEDIF(E3,TODAY(),"Y") & "." &
DATEDIF(E3,TODAY(),"YM") & "." &
DATEDIF(E3,TODAY(),"MD")
)
In Excel, a date is stored as a number of days since 1/1/1900 (or 1904, not very important), you can subtract date2-date1 and that will return the number of days between the 2 dates.
With that logic, a simple formula to get your age from your birth date stored in E3 would be:
=INT((TODAY()-E3)/365)
Just for fun, enter a date in a cell, then Clear Formats. You will see the number of days.

how to get difference between two dates in sharepoint calculated column

how to get different between two dates: column1 "joining date" column2 "leaving date", in sharepoint calculated column as "total experience of an employee"?
The desired output I'm searching is in this format for example: "2 days 2 months 2 years".
this formula should give you the answers that you are after
= DATEDIF([Date 1],[Date 2],"MD")&" Days "& DATEDIF([Date 1],[Date 2],"YM") &" Months "& DATEDIF([Date 1],[Date 2],"Y") &" Years"
Steps:
Create a calculated column of type Single Line of text
Use the formula above.
Explanation:
Formula goes as
DATEDIF(Start_date,End_date,"Interval")
Where interval can be:
Y Calculate the number of complete years
M Calculate the number of complete months
D Calculate the number of days
YM Calculate the number of months excluding years
MD Calculate the number of days excluding years and months
YD Calculate the number of days excluding years
For 2 dates like Date 1 (31/01/2020) and Date 2 (14/05/2020), the results will be:
14 Days 3 Months 0 Years

In Excel, how do I calculate days between two dates ignoring full years?

How do I calculate relative years + days between two dates in excel? I want to know the number of years and any additional days (outside of the full years). Dividing the total days by 365 doesn't work because of leap years. For example:
Cell A1 = '1/31/2015'
Cell B1 = '2/1/2025'
Cell C1 = '2/11/2025'
=(B1-A1)/365 # 10.0109 = 10 years + 4 days, looking for 10 years + 0 days
=(C1-A1)/365 # 10.0383 = 10 years + 14 days, looking for 10 years + 10 days
Is there an easy way to calculate this?
Note - this question is not a duplicate of How to find the difference between dates in VBA -- which is a question about calculating the difference between dates. This question is asking how to calculate the difference of both years and days, such that the difference in days is for the final year only, and are not incorrectly including leap year days for previous years.
You can use the documented function DATEDIF
=DATEDIF(startdate,enddate,"Y")
This will give you the difference in whole years
“Y” Returns the period difference as complete years.
“M” Returns the period difference as complete months.
“D” Returns the number of days in the period.
“MD” Returns the difference between the days in ‘Start_Date’ and ‘End_Date’. Here the months and years of the dates are ignored.
“YM” Returns the difference between the months in ‘Start_Date’ and ‘End_Date’. Here the days and years of the dates are ignored
“YD” Returns the difference between the days of ‘Start_Date’ and ‘End_Date’. Here the years of the dates are ignored.
Excel Solution :
=DATEDIF(A1,A2,"y") & " years, " & DATEDIF(A1,A2,"ym") & " months, " & DATEDIF(A1,A2,"md") & " days"
Please refer this link

How to calculate total number of days in between two dates in groovy [duplicate]

This question already has answers here:
Duration between two dates in Groovy
(2 answers)
Closed 9 years ago.
How to calculate total number of months and year in between two dates in groovy
date1 =2012 nov 1
date2 =2013 feb 1
required output is year = 0 and month =3.
Any answer is helpful
I think this should do:
monthBetween = (start[Calendar.MONTH] - end[Calendar.MONTH]) + 1
yearsBetween = start[Calendar.YEAR] - end[Calendar.YEAR]
months = monthBetween + (yearsBetween * 12)
Taken from Calculate difference in months between two dates with Groovy

Excel - how to calculate age from 'Age in Months'

If a person's age in months is 140 how could I calculate there age in Years and Months?
So for example I would want to see:
11 Years 8 Months
To get the months: =MOD(140,12)
To get the years: =ROUNDDOWN(140/12,0)
Putting it together =ROUNDDOWN($A$1/12,0) & " Years " & MOD($A$1,12) & " Months" where $A$1 holds the value (140).

Resources