Sharepoint 计算字段以比较到期日期与今天。

huangapple go评论46阅读模式
英文:

Sharepoint Calculated Field to Compare an Expiry Date to Today

问题

我正在开发一个系统,用于记录培训的进行日期,计算其有效期,以及记录需要更新的日期。

我有一个用于记录培训到期日期的日期字段,我想要一个计算字段,用于比较今天的日期和到期日期。如果日期在6个月内或更短,则状态将为警告,如果日期已过期,则状态为已过期。

我的计划是在SharePoint列表中包含一个计算字段,该列表接收来自PowerApp的数据。

到期日期字段被计算并格式化为日期和时间字段,但仅使用日期。我的当前计算如下:

=IF(DATEDIF([TrainingLog_ExpiryDate],NOW(),"m")<=0,"已过期",IF(DATEDIF([TrainingLog_ExpiryDate],NOW(),"m")<=6,"警告",IF(DATEDIF([TrainingLog_ExpiryDate],NOW(),"m")>6,"安全","错误")))

这出现了语法错误,我真的不知道为什么,因为我除了语法错误之外没有收到任何错误。有人能帮忙吗,或者提供更好的解决方案吗?

英文:

I am working on a system to record the dates which training is undertaken, calculating how long it is valid for, and recording a date for when it is required to be updated.

I have a date field for when the Training Expires, and I want a calculated field that compares today's date to the date of expiry. If the date is 6 months away or less, then it will be in a Caution status, and if the value has gone past expiry, it is expired.

My plan is to include a Calculated Field in the sharepoint list that this is held in, receiving data from a PowerApp.

The Expiry Date field is calculated and formatted as a Date and Time Field but only uses Dates. My current calculation is this:

=IF(DATEDIF([TrainingLog_ExpiryDate],NOW(),&quot;m&quot;)=&lt;0,&quot;Expired&quot;,IF(DATEDIF([TrainingLog_ExpiryDate],NOW(),&quot;m&quot;)=&lt;6,&quot;Caution&quot;,IF(DATEDIF([TrainingLog_ExpiryDate],NOW(),&quot;m&quot;)&gt;6,&quot;Safe&quot;,&quot;Error&quot;)

This is coming up with a Syntax error, and I do not really know why as I'm getting no errors other than syntax. Can anyone help, or even offer a better solution for this?

答案1

得分: 0

=IF(TrainingLog_ExpiryDate<=TODAY(),"已过期",IF(TrainingLog_ExpiryDate<=TODAY()+180,"警告",IF(TrainingLog_ExpiryDate>TODAY()+180,"安全","错误")))

英文:

Please use following formula.

=IF(TrainingLog_ExpiryDate<=TODAY(),"Expired",IF(TrainingLog_ExpiryDate<=TODAY()+180,"Caution",IF(TrainingLog_ExpiryDate>TODAY()+180,"Safe","Error")))

Result:

Sharepoint 计算字段以比较到期日期与今天。

huangapple
  • 本文由 发表于 2023年6月1日 22:07:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/76382792.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定