Sharepoint, Calculated column, IF function and date

天涯浪子 提交于 2019-12-11 02:06:13

问题


I am trying to add a calculated column.

I have a date column containing the date a meeting is scheduled. From this column I need a code which can return if the meeting is scheduled in Q1, Q2, Q3 or Q4. I have a static code looking like this:

'=IF(Date<40269;"Q1";"Q2-4")'   (40269 is the 1. April 2010 and Date=date-column)

But I need somekind of dynamic code which can calculate the same thing next year as well, without someone having to change the number(40269). I need something like this:

'=IF(Date<01-01-&year(today);"Q1";IF(Date<01-04-&year(today);"Q2";IF(Date<01-07-&year(today);"Q3";"Q4")))'

But Sharepoint will not accept a date written like this 01-01-2010, it needs to be a number eg. 40269. The above code will only work correct for the present year, but thats all-right, since I will only use data from the present year.

Can anyone help me?


回答1:


Ahhhh... It was easier than I had anticipated. I used this function:

=IF(MONTH(Date)<4;"Q1";IF(MONTH(Date)<7;"Q2";IF(MONTH(Date)<10;"Q3";"Q4")))

Date is a column containing the date of the meetings. month() returns the number of the month. E.g., march=3.



来源:https://stackoverflow.com/questions/2162394/sharepoint-calculated-column-if-function-and-date

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!