LoginSignup
0
0

More than 3 years have passed since last update.

PowerAppsで入力された日付の年度を算出する

Posted at

日付ピッカーで設定された値から年度を算出する方法です。
大した処理ではありませんが、まだPowerAppsの関数に慣れてないので記録しておきます。

お試し用に日付ピッカーとラベルのコントロールを配置します。
image.png

ラベルのTextに以下の処理を設定します。

If(
    !IsBlankOrError(DatePicker1.Value),
    If(
        Value(
            Last(
                FirstN(
                    Split(
                        Text(DatePicker1.Value),
                        "/"
                    ),
                    2
                )
            ).Result
        ) < 4,
        Left(
            Text(
                DateAdd(
                    DatePicker1.Value,
                    -1,
                    Years
                )
            ),
            4
        ),
        Left(
            Text(DatePicker1.Value),
            4
        )
    ) & "年度",
    ""
)

解説は画像で
image.png

試しに動かしてみます。
4/1はその年が年度として設定されます。
image.png
3/31は前の年が年度として設定されます。
image.png

配列のインデックス指定(XXXXX.Result[2]とか)で取れれば楽なのになぁと思いました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0