パブリックカレンダーのビルトイン関数は、オフライン 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 を返します