すべてのプロダクト
Search
ドキュメントセンター

Dataphin:パブリックカレンダーのビルトイン関数

最終更新日:Feb 06, 2025

パブリックカレンダーのビルトイン関数は、オフライン SQL タスクでの日付計算を容易にします。このトピックでは、これらの関数のコマンド構文、パラメーターの説明、および例について概要を説明し、アプリケーションのガイダンスを提供します。

制限事項

オフライン SQL コード専用に使用できます。

ビルトイン関数のディレクトリ

サポートされているパブリックカレンダーのビルトイン関数には、以下が含まれます。

関数

機能

dpc_last_workday

day_offset に基づいて、指定された business_date に最も近い営業日を計算します。

dpc_last_label_date

day_offset に基づいて、business_date に最も近い、指定された label_code の日付を決定します。

dpc_is_labelled

パブリックカレンダー calendar_code 内の business_datelabel_code でマークされているかどうかを確認します。

dpc_is_workday

パブリックカレンダー calendar_code 内の business_date が営業日かどうかを判断します。

dpc_last_workdays

パブリックカレンダー calendar_code 内の business_date より前の最も近い periods 日/月/年サイクル内のすべての営業日を計算します。periods

dpc_workdays

パブリックカレンダー calendar_code 内の startdateenddate(両端を含む)の間にあるすべての営業日を一覧表示します。

dpc_last_labelled_workdays

パブリックカレンダー calendar_codebusiness_date より前の、business_date に最も近い periods 日/月/年サイクル内で、label_code タグが付いたすべての営業日を計算します。

dpc_labelled_workdays

パブリックカレンダー calendar_code 内の startdateenddate(両端を含む)の間にある、label_code が付いたすべての営業日を計算します。

dpc_last_workday

  • コマンド構文:

    string dpc_last_workday(string "calendar_code", string "business_date", int day_offset=1)
  • コマンドの説明:

    day_offset に基づいて、指定された business_date に最も近い営業日を計算します。

  • パラメーターの説明:

    • calendar_code: パブリックカレンダーの識別子、String 型。

    • label_code: ラベルの識別子、String 型。

    • business_date: 任意の営業日、String 型、yyyyMMdd 形式。

    • periods: サイクル数、Integer 型、デフォルトは 1 です。有効な範囲は、1d <= day_offset <= 7305d (20 年)1m <= day_offset <= 240m、または 1y <= day_offset <= 20y です。

    • timeFormat: サイクルの種類、デフォルトは d です。許可される種類は次のとおりです。

      • 日: d

      • 月: m

      • 年: y

  • 戻り値の説明:

    パブリックカレンダー calendar_codebusiness_date より前の、business_date に最も近い periods 日/月/年サイクル内で、label_code タグが付いたすべての営業日を返します。business_date 自体が営業日の場合、business_date は最初の営業日と見なされます。

  • 例:

    select dpc_last_labelled_workdays('finance_calendar','chrismas_day' ,'20231126'); --20231124 を返します
    select dpc_last_labelled_workdays('finance_calendar', 'chrismas_day' ,'20231127'); --20231127 を返します
    select dpc_last_labelled_workdays('finance_calendar', 'chrismas_day' ,'20231127', 5); --20231121,20231122,20231123,20231124,20231125 を返します
    select dpc_last_labelled_workdays('finance_calendar', 'chrismas_day' ,'20231127', m, 1); --20231030...20231127 を返します

dpc_last_label_date

  • コマンド構文:

    string dpc_last_label_date(string "calendar_code", string "business_date", string "label_code", int day_offset=1)
  • コマンドの説明:

    label_codebusiness_date に最も近い日付を day_offset に基づいて識別します。

  • パラメーターの説明:

    • calendar_code: パブリックカレンダーの識別子、String 型。

    • business_date: 任意の営業日を表す String、yyyyMMdd 形式。

    • label_code: ラベルの識別子、String 型。

    • day_offset: 最も近い日付までの日数、Integer 型、デフォルトは 1 です。有効な範囲は 1 <= day_offset <= 7305 (20 年) です。

  • 戻り値の説明:

    パブリックカレンダー calendar_codebusiness_date より前の、ラベル label_code が付いた最も近い day_offset 日付を返します。business_date 自体にラベル label_code が含まれている場合、business_date が最初の日付になります。戻り値の型は String、形式は yyyyMMdd です。yyyyMMdd

  • 例:

    select dpc_last_label_date('finance_calendar', '20231230', 'chrismas_day'); --20231225 を返します
    select dpc_last_label_date('finance_calendar', '20231225', 'chrismas_day'); --20231225 を返します
    select dpc_last_label_date('finance_calendar', '20231230', 'chrismas_day', 2); --20221225 を返します

dpc_is_labelled

  • コマンド構文:

    boolean dpc_is_labelled(string "calendar_code", string "business_date", string "label_code")
  • コマンドの説明:

    パブリックカレンダー calendar_code 内の business_datelabel_code に関連付けられているかどうかを確認します。

  • パラメーターの説明:

    • calendar_code: パブリックカレンダーを表すコード、String 型。

    • business_date: 任意の営業日を表す String、yyyyMMdd 形式。

    • label_code: タグのエンコーディング、String 型

  • 戻り値の説明:

    パブリックカレンダー calendar_code 内の business_datelabel_code が含まれているかどうかを示します。ラベルが存在する場合は True を返し、それ以外の場合は False を返します。

  • 例:

    select dpc_is_labelled('finance_calendar', '20231225', 'chrismas_day'); --True を返します

dpc_is_workday

  • コマンド構文:

    boolean dpc_is_workday(string "calendar_code", string "business_date")
  • コマンドの説明:

    パブリックカレンダー calendar_code 内の business_date が営業日かどうかを判断します。

  • パラメーターの説明:

    • calendar_code: パブリックカレンダーのコード、String 型。

    • business_date: 任意の営業日を表す String、yyyyMMdd 形式。

  • 戻り値の説明:

    パブリックカレンダー calendar_code 内の business_date が営業日かどうかを確認します。営業日の場合は True を返し、それ以外の場合は False を返します。

  • 例:

    select dpc_is_workday('finance_calendar', '20231128'); --True を返します
    select dpc_is_workday('finance_calendar', '20231202'); --False を返します

dpc_last_workdays

  • コマンド構文:

    string dpc_last_workdays(string <calendar_code>, string <business_date>, int <periods>, string <timeFormat>)
  • コマンドの説明:

    公開カレンダー calendar_code 内の business_date より前の、business_date に最も近い periods 日/月/年サイクル内のすべての営業日を計算します。

  • パラメーターの説明:

    • calendar_code: パブリックカレンダーのコード、String 型。

    • business_date: 任意の営業日を表す String、yyyyMMdd 形式。

    • periods: サイクル数、Integer 型、デフォルトは 1 です。有効な範囲は、1d <= day_offset <= 7305d (20 年)1m <= day_offset <= 240m、または 1y <= day_offset <= 20y です。

    • timeFormat: サイクルの種類、デフォルトは d です。許可される種類は次のとおりです。

      • 日: d

      • 月: m

      • 年: y

  • 戻り値の説明:

    パブリックカレンダー calendar_codebusiness_date より前の、business_date に最も近い periods 日/月/年サイクル内のすべての営業日を返します。business_date 自体が営業日の場合、business_date は最初の営業日と見なされます。

  • 例:

    select dpc_last_workdays('finance_calendar', '20231126'); --20231124 を返します
    select dpc_last_workdays('finance_calendar', '20231127'); --20231127 を返します
    select dpc_last_workdays('finance_calendar', '20231127', 5); --20231121,20231122,20231123,20231124,20231125 を返します
    select dpc_last_workdays('finance_calendar', '20231127', m, 1); --20231030...20231127 を返します

dpc_workdays

  • コマンド構文:

    string dpc_workdays(string <calendar_code>, string <startdate>, string <enddate>)
  • コマンドの説明:

    パブリックカレンダー calendar_code 内の startdate から enddate (両端を含む) までのすべての営業日を一覧表示します。

  • パラメーターの説明:

    • calendar_code: パブリックカレンダーを表すコード、String 型。

    • startdate: 開始営業日を表す String、yyyyMMdd 形式。

    • enddate: 終了営業日を String で指定します。形式は yyyyMMdd です。

      重要

      有効な範囲は、enddate - startdate <= 20 年 です。

  • 戻り値の説明:

    パブリックカレンダー calendar_code 内の startdate(両端を含む)と enddate(両端を含む)の間にあるすべての営業日を返します。business_date 自体が営業日の場合、business_date は最初の営業日としてカウントされます。

  • 例:

    select dpc_workdays('finance_calendar', '20231124', '20231126'); --20231124 を返します
    select dpc_workdays('finance_calendar', '20231126', '20231127'); --20231127 を返します

dpc_last_labelled_workdays

  • コマンド構文:

    string dpc_last_labelled_workdays(string <calendar_code>, string <label_code>, string <business_date>, int <periods>, string <timeFormat>)
  • コマンドの説明:

    calendar_code パブリックカレンダーにおいて、business_date より前で business_date に最も近い periods の日/月/年サイクル内の label_code タグが付いたすべての営業日を計算します。

  • パラメーターの説明:

    • calendar_code: パブリックカレンダーのコード、String 型。

    • label_code: ラベルのコード、String 型。

    • business_date: 任意の営業日、String 型、yyyyMMdd 形式。

    • periods: サイクル数、Integer 型、デフォルトは 1 です。有効な範囲は、1d <= day_offset <= 7305d (20 年)1m <= day_offset <= 240m、または 1y <= day_offset <= 20y です。

    • timeFormat: サイクルの種類、デフォルトは d です。許可される種類は次のとおりです。

      • 日: d

      • 月: m

      • 年: y

  • 戻り値の説明:

    パブリックカレンダー calendar_codebusiness_date より前の、business_date に最も近い periods 日/月/年サイクル内で、label_code タグが付いたすべての営業日を返します。business_date 自体が営業日の場合、business_date は最初の営業日と見なされます。

  • 例:

    select dpc_last_labelled_workdays('finance_calendar','chrismas_day' ,'20231126'); --20231124 を返します
    select dpc_last_labelled_workdays('finance_calendar', 'chrismas_day' ,'20231127'); --20231127 を返します
    select dpc_last_labelled_workdays('finance_calendar', 'chrismas_day' ,'20231127', 5); --20231121,20231122,20231123,20231124,20231125 を返します
    select dpc_last_labelled_workdays('finance_calendar', 'chrismas_day' ,'20231127', m, 1); --20231030...20231127 を返します

dpc_labelled_workdays

  • コマンド構文:

    string dpc_labelled_workdays(string <calendar_code>, string <label_code>, string <startdate>, string <enddate>)
  • コマンドの説明:

    指定されたパブリックカレンダー calendar_code 内で、calendar_code タグが付いた営業日の数を、startdate から enddate まで(開始日と終了日を含む)計算します。

  • パラメーターの説明:

    • calendar_code: パブリックカレンダーの識別子、String 型。

    • label_code: ラベルの識別子、String 型。

    • startdate: 開始営業日を String で指定します。形式は yyyyMMdd です。

    • enddate: 終了営業日を表す String、yyyyMMdd 形式。

      重要

      有効な範囲は、enddate - startdate <= 20 年 です。

  • 戻り値の説明:

    パブリックカレンダー calendar_code 内の startdate(両端を含む)と enddate(両端を含む)の間にある、ラベル lable_code が付いたすべての営業日を返します。business_date 自体が営業日の場合、business_date は最初の営業日としてカウントされます。

  • 例:

    select dpc_labelled_workdays('finance_calendar','chrismas_day','20231124', '20231126'); --20231124,20231126 を返します
    select dpc_labelled_workdays('finance_calendar','chrismas_day', '20231126', '20231127'); --20231126,20231127 を返します