2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Salesforceで日付から曜日を取得しよう~WEEKDAY関数

Posted at

こんにちは
本橋孝昭です

今回はSalesforceの数式項目「WEEKDAY」関数について解説します

WEEKDAY関数とは

WEEKDAY関数を使えば特定の日付項目の曜日を確認し[1]から「7」を表示させます
1は月曜日、7は日曜日を表します

※参考ヘルプ
https://help.salesforce.com/s/articleView?id=000384282&type=1

しかしながら、通常のWEEKDAY関数だと数字のみが表示されます
なので例えば

WEEKDAY(test01__c)
※test01__cは日付項目のAPI参照名とする

のような数式の場合、返す値は1や2となり、通常であればわかりにくいので
「1は月曜日と表示させたい」という話も多く出てきます

WEEKDAY関数 応用例

そこで、WEEKDAY関数を使い月曜日から日曜日と返す数式は以下となります

IF(ISBLANK(test01__c),"空欄です",
CASE(WEEKDAY(test01__c),1, "日曜日",
2, "月曜日",
3, "火曜日",
4, "水曜日",
5, "木曜日",
6, "金曜日",
"土曜日"))
※test01__cは日付項目のAPI参照名とする

このような数式項目(テキスト型)を使えば、
日付項目の日付が何曜日であるか を返すことが出来るのでとても便利です

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?