I need to calculate the time difference between two dates in Formula language or LotusScript and then return the result in the format of "x months and y days." Do you know of any scripts or @Formulas that can do this?
I used a formula to calculate the difference. This does not include code for leap year and assumes that date1, the first date, is always earlier than date2. Here's the formula for a text field.
year1 := @IF(date1=""; 0; @Year(date1)); year2 := @IF(date2=""; 0; @Year(date2)); month1:= @IF(date1=""; 0; @Month(date1)); month2:= @IF(date2=""; 0; @Month(date2)); day1 := @IF(date1=""; 0; @day(date1)); day2 := @IF(date2=""; 0; @day(date2)); daysinmonth := @IF(date1=""; 0; @Select(month1;31;28;31;30;31; 30;31;31;30;31;30;31)); tempmonth:[email protected] (year1=year2; month2 - month1; ((year2-year1)*12) + month2 - month1); months:[email protected](day2<day1; tempmonth - 1; tempmonth); days:[email protected](day1<=day2; day2 - day1; daysinmonth + day2 - day1); "sample: " + @text(months) + " months and " + @Text(days) + " days."
Dig Deeper on Lotus Notes Domino Formula Language
Related Q&A from Brian Mahoney
Find out what types of calculations can be computed for a column in a Lotus Notes view and the best way to go about it with this expert response. Continue Reading
Find out why you can't use Formula language to include a doclink to a specific Lotus Notes view or database and need to use LotusScript instead. Continue Reading
SearchDomino.com's expert Brian Mahoney explains how to work around the default replication and form parameters of profile documents, so that the ... Continue Reading