1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Power Apps】DateDiff関数とは、使い方

Posted at

DateDiff関数の使い方と活用例

この記事では、DateDiff関数の概要と基本的な使い方、活用例を紹介します。

この記事は Microsoft Power Apps Advent Calendar 2024 シリーズ3 12月4日 担当分の記事です。

関数説明・構文

2 つの日付/時刻値の差を返します。 この結果は、単位の整数です。

引用元: Microsoft公式ドキュメント

DateDiff(StartDate, EndDate, TimeUnit)
StartDate:差を計算する開始日
EndDate:差を計算する終了日
TimeUnit:差を計算する単位(Days、Months、Years、Hours、Minutes、Seconds)

使い方

二つの日時の差を算出します。日や時間の差分計算でよく使います。

日単位での計算

1582年10月4日から1582年10月15日までの日数を計算する例です。

DateDiff(DateValue("1582/10/4"), DateValue("1582/10/15"), TimeUnit.Days)

image.png

結果は11となります。

年単位での計算

1978年9月17日から本日(2024年12月19日)までの年数を計算します。

DateDiff(DateValue("1978年9月17日"), Today(), TimeUnit.Years)

image.png

結果は46となります。

時間単位での計算

1969/7/20 20:17:00から1969/7/21 17:54:00までの時間差を計算する例です。

DateDiff(
    DateTimeValue("1969-07-20 20:17:00"),
    DateTimeValue("1969-07-21 17:54:00"),
    TimeUnit.Hours
)

image.png

結果は21となります。

元記事

1
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?