パブリックカレンダーのビルトイン関数は、オフライン SQL タスクでの日付計算を容易にします。このトピックでは、これらの関数のコマンド構文、パラメーターの説明、および例について概要を説明し、アプリケーションのガイダンスを提供します。
制限事項
オフライン SQL コード専用に使用できます。
ビルトイン関数のディレクトリ
サポートされているパブリックカレンダーのビルトイン関数には、以下が含まれます。
関数 | 機能 |
| |
| |
パブリックカレンダー | |
パブリックカレンダー | |
パブリックカレンダー | |
パブリックカレンダー | |
パブリックカレンダー | |
パブリックカレンダー |
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_codeのbusiness_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_codeがbusiness_dateに最も近い日付をday_offsetに基づいて識別します。パラメーターの説明:
calendar_code: パブリックカレンダーの識別子、String 型。
business_date: 任意の営業日を表す String、
yyyyMMdd形式。label_code: ラベルの識別子、String 型。
day_offset: 最も近い日付までの日数、Integer 型、デフォルトは
1です。有効な範囲は1 <= day_offset <= 7305 (20 年)です。
戻り値の説明:
パブリックカレンダー
calendar_codeのbusiness_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_dateがlabel_codeに関連付けられているかどうかを確認します。パラメーターの説明:
calendar_code: パブリックカレンダーを表すコード、String 型。
business_date: 任意の営業日を表す String、
yyyyMMdd形式。label_code: タグのエンコーディング、String 型。
戻り値の説明:
パブリックカレンダー
calendar_code内のbusiness_dateにlabel_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_codeのbusiness_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_codeのbusiness_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 を返します