引用:
年齢計算で何年何ヶ月表記をしたい
(詳細エディター)
-------------------------------------------------------
let GetText = (birthday as date) =>
let
CurrentDate = Date.From(DateTimeZone.SwitchZone(DateTimeZone.UtcNow(), 9)),
YearDiff = Date.Year(CurrentDate) - Date.Year(birthday),
MonthDiff = Date.Month(CurrentDate) - Date.Month(birthday),
IsNotBirthdayComing = if Date.Day(birthday) > Date.Day(CurrentDate)
then -1
else 0,
MonthsCount = (YearDiff * 12) + MonthDiff + IsNotBirthdayComing,
GetYearMonth = if MonthsCount < 0
then null
else Number.ToText(Number.IntegerDivide(MonthsCount, 12)) & "歳" &
Number.ToText(Number.Mod(MonthsCount, 12)) & "ヶ月"
in
GetYearMonth
in
GetText
-------------------------------------------------------
とりあえず、以上のようなカスタム関数を作成なさればよろしいのではないかと。