Modelerデータ加工Tips#08コード
Modelerデータ加工TIPS#08 サンプルコード
Nヶ月後の日付を求めるフィールド作成
Clem式
if datetime_month(起算日)+6 > 12
# Nヵ月後が次の年になる場合
then if member(datetime_month(起算日) +6-12, [4 6 9 11]) and datetime_day(起算日) = 31
# 小の月
then datetime_date(datetime_year(起算日)+1, datetime_month(起算日)+ 6 -12, 30)
else if datetime_month(起算日)+6-12 = 2 and member(datetime_day(起算日), [29 30 31])
then if (datetime_year(起算日)+1) rem 4 = 0 and ((datetime_year(起算日)+1) rem 100 /= 0 or (datetime_year(起算日)+1) rem 400 = 0)
# 2月うるう年
then datetime_date(datetime_year(起算日)+1, 2, 29)
# 2月平年
else datetime_date(datetime_year(起算日)+1, 2, 28)
endif
# 大の月
else datetime_date(datetime_year(起算日)+1, datetime_month(起算日)+6-12, datetime_day(起算日))
endif
endif
# Nヵ月後が年内の場合
else if member(datetime_month(起算日)+6, [4 6 9 11]) and datetime_day(起算日) = 31
# 小の月
then datetime_date(datetime_year(起算日), datetime_month(起算日)+6, 30)
else if datetime_month(起算日)+6 = 2 and member(datetime_day(起算日), [29 30 31])
then if datetime_year(起算日) rem 4 = 0 and (datetime_year(起算日) rem 100 /= 0 or datetime_year(起算日) rem 400 = 0)
# 2月うるう年
then datetime_date(datetime_year(起算日), 2, 29)
# 2月平年
else datetime_date(datetime_year(起算日), 2, 28)
endif
# 大の月
else datetime_date(datetime_year(起算日), datetime_month(起算日)+6, datetime_day(起算日))
endif
endif
endif
Modelerデータ加工TIPS#08 サンプルコード2
パラメータを使ってスーパーノード化する場合
Clem式
if datetime_month(起算日)+'$P-month' > 12
# Nヵ月後が次の年になる場合
then if member(datetime_month(起算日)+'$P-month'-12, [4 6 9 11]) and datetime_day(起算日) = 31
# 小の月
then datetime_date(datetime_year(起算日)+1, datetime_month(起算日)+'$P-month'-12, 30)
else if datetime_month(起算日)+'$P-month'-12 = 2 and member(datetime_day(起算日), [29 30 31])
then if (datetime_year(起算日)+1) rem 4 = 0 and ((datetime_year(起算日)+1) rem 100 /= 0 or (datetime_year(起算日)+1) rem 400 = 0)
# 2月うるう年
then datetime_date(datetime_year(起算日)+1, 2, 29)
# 2月平年
else datetime_date(datetime_year(起算日)+1, 2, 28)
endif
# 大の月
else datetime_date(datetime_year(起算日)+1, datetime_month(起算日)+'$P-month'-12, datetime_day(起算日))
endif
endif
# Nヵ月後が年内の場合
else if member(datetime_month(起算日)+'$P-month', [4 6 9 11]) and datetime_day(起算日) = 31
# 小の月
then datetime_date(datetime_year(起算日), datetime_month(起算日)+'$P-month', 30)
else if datetime_month(起算日)+'$P-month' = 2 and member(datetime_day(起算日), [29 30 31])
then if datetime_year(起算日) rem 4 = 0 and (datetime_year(起算日) rem 100 /= 0 or datetime_year(起算日) rem 400 = 0)
# 2月うるう年
then datetime_date(datetime_year(起算日), 2, 29)
# 2月平年
else datetime_date(datetime_year(起算日), 2, 28)
endif
# 大の月
else datetime_date(datetime_year(起算日), datetime_month(起算日)+'$P-month', datetime_day(起算日))
endif
endif
endif
Author And Source
この問題について(Modelerデータ加工Tips#08コード), 我々は、より多くの情報をここで見つけました https://qiita.com/416nishimaki/items/8445c56337ef296368d8著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .