简体   繁体   English

用于将DATE作为TEXT计算的公式

[英]Formula to calculate DATE as TEXT

I have searched online and in forums but can´t find any solution for this. 我已经在网上和论坛中搜索过,但是找不到任何解决方案。

I want to calculate date as TEXT in Sharepoint list with calculated fields. 我想在带有计算字段的Sharepoint列表中将日期计算为TEXT。

It works to calculate well with the formula below, but it prints the date like this "2018-07-06T22:00:00Z" 它可以使用下面的公式很好地计算出结果,但它打印的日期是这样的:“ 2018-07-06T22:00:00Z”

=IF(ISBLANK([Contract Start]);"";DATE(YEAR([Contract Start]);MONTH([Contract Start])+[ContractLength];DAY([Contract Start]))) = IF(ISBLANK([Contract Start]);“”; DATE(YEAR([Contract Start]); MONTH([Contract Start])+ [ContractLength]; DAY([Contract Start]))))

I have tried the following formula, and it gives me the date in the format i wish "2018-07-06" but i can´t get it to add months from column [ContractLength] to the date. 我已经尝试过以下公式,但它以我希望“ 2018-07-06”的格式给出日期,但我无法将其从[ContractLength]列添加月份到日期。

=IF(ISBLANK([ContractStarts]);””;CONCATENATE(TEXT([ContractStarts];"yyyy");"-";TEXT([ContractStarts];"MM");"-";TEXT([ContractStarts];"dd"))) = IF(ISBLANK([ContractStarts]);””; CONCATENATE(TEXT([ContractStarts]; “YYYY”); “ - ”; TEXT([ContractStarts]; “MM”); “ - ”; TEXT([ContractStarts] ; “DD”)))

So I need help with a formula that adds the specified number of months from the [ContractLength] column to the start date [ContractStarts] column in the SharePoint list, and print it as TEXT so we get the date printed "2018-07-06". 因此,我需要一个公式的帮助,该公式将[ContractLength]列中指定的月数添加到SharePoint列表中的开始日期[ContractStarts]列中,并将其打印为TEXT,这样我们就可以得到打印日期为“ 2018-07-06 ”。

Thanks in advance! 提前致谢!

I'm not quite sure what you mean with "calculate date as text". 我不太确定“将日期计算为文本”的意思。 If you mean you want to show the result as text, not a date, then you can use this formula. 如果您想将结果显示为文本而不是日期,则可以使用此公式。

=IF(ISBLANK(ContractStarts);"";TEXT(DATE(YEAR(ContractStarts);MONTH(ContractStarts)+ContractLength;DAY(ContractStarts));"yyyy-mm-dd"))

Or, if you want the result to be a date, then this formula works fine, too, but you need to select "Date" as the data type of the calculated column and tick the button for Date only. 或者,如果您希望结果为日期,则此公式也可以正常工作,但是您需要选择“日期”作为计算列的数据类型,然后仅选中日期按钮。

=IF(ISBLANK(ContractStarts);"",DATE(YEAR(ContractStarts);MONTH(ContractStarts)+ContractLength;DAY(ContractStarts))) 

在此处输入图片说明

The screenshot below shows both formulas at work in the SharePoint list. 下面的屏幕快照显示了SharePoint列表中的两个公式。

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM