我有兩個字段計算兩個日期開始日期和結束日期的星期數。所以我有兩個領域叫FirstWeek和LastWeek。我想找到FirstWeek和LastWeek之間的所有數字,並將這些數字放在另一個字段中。蓮花公式找到兩個數字之間的所有數字
例如firstweek = 35 過去一週= 39
欲場周= 35,36,37,38,39
任何想法將不勝感激。如果可能的話,我想使用公式。
我有兩個字段計算兩個日期開始日期和結束日期的星期數。所以我有兩個領域叫FirstWeek和LastWeek。我想找到FirstWeek和LastWeek之間的所有數字,並將這些數字放在另一個字段中。蓮花公式找到兩個數字之間的所有數字
例如firstweek = 35 過去一週= 39
欲場周= 35,36,37,38,39
任何想法將不勝感激。如果可能的話,我想使用公式。
在@Formula語言中,你也有For循環。如果你有號碼字段firstweek和號碼字段過去一週您可以創建數場周,我的建議是,這是一個多值字段,並嘗試這個公式:
REM {firstweek_date is the date field from which you are calculating the value of firstweek number};
year_firstweek := @Year(firstweek_date);
REM {lastweek_date is the date field from which you are calculating the value of lastweek number};
year_lastweek :[email protected](lastweek_date);
REM {if the year diff is one then the first value of weeks field is first week};
REM {NOTE: I took that every year has 52 weeks.};
REM {If this is not OK then for number_of_weeks_in_year set the value in a same way as you are doing with firstweek but for date @Date(year_firstweek ; 12 ; 31).};
REM {If the dates are in same Year then as written before you can use the same logic};
REM {Otherwise I set field week to 0};
@If((year_lastweek-year_firstweek) = 1;
@Do(
FIELD weeks := firstweek;
number_of_weeks_in_year := 52;
@For(n := firstweek+1; n <= number_of_weeks_in_year; n := n + 1;FIELD weeks := weeks:n);
@For(n := 1; n <= lastweek; n := n + 1;FIELD weeks := weeks:n)
);
(year_lastweek-year_firstweek) = 0;
@Do(
FIELD weeks := firstweek;
@For(n := firstweek+1; n <= lastweek; n := n + 1;FIELD weeks := weeks:n)
);
FIELD weeks := 0
)
歡迎的StackOverflow!你有什麼嘗試?請參閱[mcve]和[問]如何提出好問題。 – SevenEleven
這裏的答案不可能比您在IBM Lotus Notes/Domino 8.5論壇上收到的答案更好: http://www-10.lotus.com/ldd/nd85forum.nsf/ShowMyTopicsAllFlatweb/041e0cdf49882a4f8525817f004cf406? OpenDocument –
你真正的問題,你沒有提到上面,仍然是間隔從一年到下一個。無論你使用兩個從「01」到「52」/「53」和@Subset連接的列表還是使用循環,都必須考慮當前是否有52個編號的星期53.其餘的很容易。 –