- カテゴリ:
EXTRACT¶
Extracts the specified date or time part from a date, interval, time, or timestamp.
Tip
タイムスタンプから日付を抽出するには、 TO_DATE 関数を使用します。
構文¶
引数¶
date_or_time_partThe unit of time. Must be one of the values listed in サポートされている日付と時刻の部分 (for example,
month). The value can be a string literal or can be unquoted (for example,'month'ormonth).date_or_time_partがweek(またはそのバリエーション)の場合、出力は WEEK_START セッションパラメーターによって制御されます。date_or_time_partがdayofweekまたはyearofweek(またはそれらのバリエーション)の場合、出力は WEEK_OF_YEAR_POLICY および WEEK_START セッションパラメーターによって制御されます。
例などの詳細については、 カレンダーの週と平日 をご参照ください。
date_interval_time_or_timestamp_exprA date, an interval, a time, or a timestamp, or an expression that can be evaluated to one of those data types.
戻り値¶
NUMBER データ型の値を返します。
使用上の注意¶
When
date_interval_time_or_timestamp_expris a year-month interval value, the supporteddate_or_time_partvalues areyearandmonth.When
date_interval_time_or_timestamp_expris a day-time interval value, the supporteddate_or_time_partvalues areday,hour,minute,second, andnanosecond.Currently, when
date_interval_time_or_timestamp_expris a DATE value, the followingdate_or_time_partvalues aren't supported:epoch_millisecondepoch_microsecondepoch_nanosecond
その他の 日付と時刻の部分 (
epoch_secondを含む)がサポートされています。
例¶
year の部分を指定して、タイムスタンプから年を抽出します。
現在の曜日の完全な名前を返すには、 EXTRACT を DECODE 関数と dayofweek の部分と一緒に使用します。
注釈
出力は、クエリを実行したときに SYSTIMESTAMP 関数から返される値に依存します。 DAYNAME 関数を使用して、指定した日付またはタイムスタンプから3文字の曜日名を抽出することもできます。