

 Amazon Redshift 將不再支援從修補程式 198 開始建立新的 Python UDFs。現有 Python UDF 將繼續正常運作至 2026 年 6 月 30 日。如需詳細資訊，請參閱[部落格文章](https://aws.amazon.com/blogs/big-data/amazon-redshift-python-user-defined-functions-will-reach-end-of-support-after-june-30-2026/)。

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 日期、時間和時間戳記常值
<a name="r_Date_and_time_literals"></a>

以下是 Amazon Redshift 所支援日期、時間和時間戳記常值的規則。

## 日期
<a name="r_Date_and_time_literals-dates"></a>

下列輸入日期全都是 DATE 資料類型的有效常值日期值範例，可以載入 Amazon Redshift 資料表中。假設預設 `MDY DateStyle` 模式有效。此模式表示在字串中月份值位於日期值之前，例如 `1999-01-08` 和 `01/02/00`。

**注意**  
載入資料表時，日期或時間戳記常值必須用引號括住。

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/redshift/latest/dg/r_Date_and_time_literals.html)

## Times
<a name="r_Date_and_time_literals-times"></a>

下列輸入時間全都是 TIME 和 TIMETZ 資料類型的有效常值時間值範例，可以載入 Amazon Redshift 資料表中。

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/redshift/latest/dg/r_Date_and_time_literals.html)

## 時間戳記
<a name="r_Date_and_time_literals-timestamps"></a>

下列輸入時間戳記全都是 TIMESTAMP 和 TIMESTAMPTZ 資料類型的有效常值時間值範例，可以載入 Amazon Redshift 資料表中。有效的日期常值全都可以和下列的時間常值合併。

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/redshift/latest/dg/r_Date_and_time_literals.html)

## 特殊的日期時間 (Datetime) 值
<a name="r_Date_and_time_literals-special-datetime-values"></a>

下列的特殊值可做為日期時間 (datetime) 常值和日期函式的引數使用。這些值需使用單引號，而且會在查詢處理作業進行期間，轉換為一般的時間戳記值。

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/redshift/latest/dg/r_Date_and_time_literals.html)

下列範例顯示 `now` 和 `today` 如何與 DATEADD 函數搭配使用。

```
select dateadd(day,1,'today');

date_add
---------------------
2009-11-17 00:00:00
(1 row)

select dateadd(day,1,'now');

date_add
----------------------------
2009-11-17 10:45:32.021394
(1 row)
```