-
1. Re: Calculate Difference in Years, Months and Days between Two Dates
venkata sreekanth Jul 26, 2016 12:22 AM (in response to sreekanth kancharla)1 of 1 people found this helpfulHi,
Use DateDiff function.The syntax is like
1.DateDiff('year',[Start Date],[End Date])
2.DateDiff('month',[Start Date],[End Date])
3.DateDiff('day',[Start Date],[End Date])
regards,
Venkata Sreekanth -
2. Re: Calculate Difference in Years, Months and Days between Two Dates
Ashish Chaudhari Jul 26, 2016 12:28 AM (in response to sreekanth kancharla)Hi Sreekanth,
Please find the below attached code, result screenshot and .twbx file (9.3).
Name - Calc_Format
IF (DATEDIFF('day',[Start Date],[End Date]))/30<1 then "0 Year 0 Month "+STR(DATEDIFF('day',[Start Date],[End Date]))+" Days"
ELSEIF (DATEDIFF('day',[Start Date],[End Date]))/30<12 THEN "0 Year "+STR( ((int(DATEDIFF('day',[Start Date],[End Date])))-(DATEDIFF('day',[Start Date],[End Date])%30))/30)+" Months "+STR(DATEDIFF('day',[Start Date],[End Date])%30)+" Days"
ELSEIF (DATEDIFF('day',[Start Date],[End Date]))/30>12 THEN STR( INT((((int(DATEDIFF('day',[Start Date],[End Date])))-(DATEDIFF('day',[Start Date],[End Date])%30))/30)/12))+" Year "+STR( (((int(DATEDIFF('day',[Start Date],[End Date])))-(DATEDIFF('day',[Start Date],[End Date])%30))/30)%12)+" Months "+STR(DATEDIFF('day',[Start Date],[End Date])%30)+" Days"
END
Thanks and Regards,
Ashish Chaudhari
-
Year Month Day format.twbx 31.4 KB
-
-
3. Re: Calculate Difference in Years, Months and Days between Two Dates
sreekanth kancharla Jul 26, 2016 7:10 AM (in response to Ashish Chaudhari)Thanks for the Ashish Chaudhari.