英文:
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(),"m")=<0,"Expired",IF(DATEDIF([TrainingLog_ExpiryDate],NOW(),"m")=<6,"Caution",IF(DATEDIF([TrainingLog_ExpiryDate],NOW(),"m")>6,"Safe","Error")
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,"安全","错误")))
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论