> For the complete documentation index, see [llms.txt](https://lochiwei.gitbook.io/web/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lochiwei.gitbook.io/web/appendix/gas/tips/xian-shi-zhong-wen-xing-qi-ji.md).

# 顯示中文星期幾

{% hint style="warning" %}
注意：如果星期幾出現英文，記得到「檔案 > <mark style="color:red;">**試算表設定**</mark>」中更改<mark style="color:red;">**語言**</mark>。
{% endhint %}

{% tabs %}
{% tab title="📗 參考" %}

* [Google 試算表好用函式：weekday() 根據日期自動產生星期幾](https://smarter01.com/function-weekday/) - 文中雖然介紹要用 WEEKDAY 函數，但只要直接對日期使用文中介紹的「格式 > 數值 > 其他格式 > 更多日期和時間格式」就可以了。
* [Google Sheets Functions – NOW, TODAY, DAY, MONTH, YEAR](https://www.bazroberts.com/2016/11/14/google-sheets-functions-now-today-day-month-year/) - 今年：<mark style="color:red;">**YEAR(TODAY())**</mark>&#x20;
  {% endtab %}

{% tab title="📘 手冊" %}

* Google Help ⟩&#x20;
  * [WEEKDAY](https://support.google.com/docs/answer/3092985?hl=en)
  * [YEAR](https://support.google.com/docs/answer/3093061?hl=en)
  * [Format numbers in a spreadsheet](https://support.google.com/docs/answer/56470)
    {% endtab %}
    {% endtabs %}

## custom function

```javascript
/**
 * 將 0 ~ 6 轉為 "星期一" ～ "星期日"
 * 用 =weekdayName(WEEKDAY(date, 3)) 來轉換
 * @customfuction
 */
function weekdayName(n) {
  const a = ["一", "二", "三", "四", "五", "六", "日"];
  return '星期' + a[n];
}
```
