English 中文(简体)
No of Years, Month and Days
原标题:

I created Lotus Notes database for HR Department. I entered field Join date. Also entered field “Total Service Period”. I want get the calculated Number of Years, Month and Days of service in to “View” and to update the service period daily.

问题回答

This is just a re-posting of a formula I posted seven years ago in the Lotus Notes and Domino 4 and 5 forum:

startDate := Time1;
endDate := Time2;
startDay := @Day(startDate);
endDay := @Day(endDate);
startMonth := @Month(StartDate);
endMonth := @Month(endDate);
startYear := @Year(startDate);
endYear := @Year(endDate);
lessAYear := @If(endMonth > startMonth;@False; (endMonth = startMonth) & (endDay >= startDay); @False; @True);
yearsDiff := @If(lessAYear; endYear - startYear - 1; endYear - startYear);
@Set("endDate"; @Adjust(endDate;-yearsDiff;0;0;0;0;0));
monthAdj := @If(startDay>endDay;-1;0);
monthsDiff := @If(lessAYear; (endMonth + 12) - startMonth + monthAdj; endMonth - startMonth + monthAdj);
@Set("endDate";@Adjust(endDate;0;-monthsDiff;0;0;0;0));
daysDiff := @Integer((endDate - startDate)/86400);
@Prompt([Ok];"";@Text(yearsDiff) + "years, " + @Text(monthsDiff) + " months, and " + @Text(daysDiff) + " days.")

Didn t test this one fully, but just for the fun I wanted to share this formula:

diff:= @Adjust(endDate; -@Year(startDate); -@Month(startDate)+1;
               -@Day(startDate)+1; 0; 0; 0);
y:= @Year(diff);
y:= @If(@IsError(n); 0; n>100; 0; n)

I assume months and days can be calculated in a similar way.





相关问题
Calling Lotus Script Function From Lotus Formula

I need to call a lotus script function from Lotus Formula. The function returns a result. I do not just want to run a script which does not return any value. This is for Lotus Notes 7. Example ...

Open an attachment for editing and save changes made to it

My Lotus Notes document has a rich text item that stores an attachment. I want to edit the attachment and after this to save the attachment back to the Lotus Notes document. This is the script that ...

No of Years, Month and Days

I created Lotus Notes database for HR Department. I entered field Join date. Also entered field “Total Service Period”. I want get the calculated Number of Years, Month and Days of service in to “View”...

How to add a field from a 2nd form?

I m modifying an existing Lotus view to include a field from another form. I first appended a new column and set it to the desired field. However, after I refreshed, the new column was blank even ...

How do I select all documents manager

I m new to Lotus development and I need to create a view that shows where the user is manager of another database besides its own mail. Thanks in advance for any help.

热门标签