莲花公式查找两个数字之间的所有数字
lotus formula to find all numbers between two numbers
我有两个字段计算两个日期开始日期和结束日期的周数。所以我有两个字段称为 FirstWeek 和 LastWeek。我想找到 FirstWeek 和 LastWeek 之间的所有数字并将它们放在另一个字段中。
例如第一周= 35
上周 = 39
我想要实地周数= 35, 36, 37, 38, 39
如有任何想法,我们将不胜感激。如果可能的话,我想使用公式。
在@Formula 语言中,您也有 For 循环。如果你有数字字段 firstweek 和数字字段 lastweek 你可以创建数字字段 weeks,我的建议是这是一个多值字段,然后试试这个公式:
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 :=@Year(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
)
我有两个字段计算两个日期开始日期和结束日期的周数。所以我有两个字段称为 FirstWeek 和 LastWeek。我想找到 FirstWeek 和 LastWeek 之间的所有数字并将它们放在另一个字段中。
例如第一周= 35 上周 = 39
我想要实地周数= 35, 36, 37, 38, 39
如有任何想法,我们将不胜感激。如果可能的话,我想使用公式。
在@Formula 语言中,您也有 For 循环。如果你有数字字段 firstweek 和数字字段 lastweek 你可以创建数字字段 weeks,我的建议是这是一个多值字段,然后试试这个公式:
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 :=@Year(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
)