---
schema_version: "1"
id: 2d529f3460628c3f0caee3de58221ac95500722d0e0c58bf66949c1e18465906
title: 自訂日期
collection: tableau
version: next
locale: zh-tw
portal_url: https://docs.salesforce.com/tableau/next/zh-tw/public/desktop/dates_custom.md
canonical_url: https://help.tableau.com/v0.0/public/desktop/zh-tw/dates_custom.htm
source_site: help.tableau.com
content_type: documentation
content_hash: 103410c67e3ec21d50285c13ef0dd732ec9ca0bb6c69fc6a26bfd92a7b2ab77f
description: Create custom dates using DATEPART or DATETRUNC to work at a specific date level.
---
[跳至主要內容](#main-content)

# 自訂日期

若總是在特定層級使用日期，或者若想要建立依賴於量化或截斷日期的計算，自訂日期很有用。

可以在資料窗格中建立自訂日期，或使用 `DATEPART` 或 `DATETRUNC` 函數編寫計算。

1. 在資料窗格中以右鍵按一下（在 Mac 上，Control + 按一下）日期欄位，並選取建立 > 建立自訂日期。
2. 從詳細資料清單中，選取想要的層級。
3. 指定希望自訂日期為離散（日期部分），還是連續（日期值）。
    
    ![用於建立自訂日期篩選器的介面，其中包含按季度詳細說明的選項。](/tableau/next/zh-tw/public/desktop/zh-tw/Img/customdate1.png)
4. 可選：為欄位輸入自己的名稱。
5. 完成後，按一下確定。

以這種方式建立的自訂日期在資料窗格中顯示為新欄位。

## 範例 - 將列標題的格式設定為年/月/日

此範例使用\[範例 - 超級市場\]資料來源。

1. 將 \[\[Order Date\]\] （\[訂單日期\]）拖到 \[欄\] 上。
2. 將 \[銷售額\] 拖到 \[列\]。
3. 以右鍵按一下 \[欄\] 架上的 \[Order Date\]（訂單日期），並選取 \[更多\] \> \[自訂\] 。
4. 在 \[自訂日期\] 對話方塊中，從 \[詳細資料\] 下拉清單中選取 \[年/月/日\] 。

檢視現在的列標題將以正確格式顯示：

![2011 年 1 月4 日至 2 月 2 日銷售趨勢折線圖。](/tableau/next/zh-tw/public/desktop/zh-tw/Img/month_day_year.png)