年、月、日数

发布于 2024-09-10 10:51:47 字数 96 浏览 0 评论 0原文

我为人力资源部门创建了 Lotus Notes 数据库。我输入了“加入日期”字段。还输入“总服务期”字段。我想将计算出的服务年数、月份和天数输入到“查看”中,并每天更新服务期限。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

哭了丶谁疼 2024-09-17 10:51:47

这只是我发布的公式的重新发布 七年前在 Lotus Notes 和 Domino 4 和 5 论坛中:

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.")

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.")
在你怀里撒娇 2024-09-17 10:51:47

没有完全测试这个,但只是为了好玩,我想分享这个公式:

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)

我假设月和日可以用类似的方式计算。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文