2017-08-17 16 views
0

Iveは2つの日付の開始日と終了日の週数を計算する2つのフィールドを持っています。だからFirstWeekとLastWeekという2つのフィールドがあります。私はFirstWeekとLastWeekの間のすべての数字を見つけて、それらを別のフィールドに入れたいと思っています。2つの数字の間のすべての数字を見つけるためのLotusの式

インスタンスfirstweekについて

= 35 lastweek = 39

Iフィールド週間たい= 35、36、37、38、39

任意の考えは非常に高く評価されるだろう。私は可能な限り式を使用したいと思います。

+0

はStackOverflowのへようこそ!何を試しましたか?良い質問をするには、[mcve]と[ask]を参照してください。 – SevenEleven

+0

ここでの回答は、すでにIBM Lotus Notes/Domino 8.5フォーラムで受け取ったものよりも優れているとは思えません。 http://www-10.lotus.com/ldd/nd85forum.nsf/ShowMyTopicsAllFlatweb/041e0cdf49882a4f8525817f004cf406? OpenDocument –

+0

上記で言及しなかったあなたの本当の問題は、まだ1年から次の期間に及ぶ間隔です。 "01"から "52"/"53"と@Subsetまたはループで2つの連結されたリストを使用するかどうかにかかわらず、現在の年が53の52週の週を持つかどうかを考慮する必要があります。 –

答えて

1

@Formula言語では、Forループも使用できます。あなたが番号フィールドfirstweekと番号フィールドlastweekを持っている場合は、番号フィールドを作成することができ、私のアドバイスは、これは複数値フィールドであることであり、この式を試してみてください。

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 
) 
+0

これは素晴らしいです。私が今問題を抱えているのは、最初の1週間が2017で、最後の1週間が2018であれば、最初の1週間だけです。何かご意見は? – James

+0

最初の週から先週までの最大の違いは何ですか?たとえば2016年の最初の週、2020年の先週の週、またはその範囲は常に最大です。一年? – Strahil

+0

それはおそらく1年に及ぶだけでしょう。 2017 to 2018 – James

関連する問題