1
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.

深夜の労働時間を計算する数式

Last updated at Posted at 2022-03-22

Answersで回答する時に使う情報のまとめ

いやぁ、Timeフィールドの扱いに困りました。なかなかうまく計算できませんでしたね。
ポイントはstart_time__c と end_time__cの関係によって式を変える必要がありました。

04:00~13:00と22:00~05:00では計算式が違いました。

IF( start_time__c <= end_time__c ,

IF( AND(start_time__c >= TIMEVALUE("05:00:00.000") ,end_time__c <= TIMEVALUE("22:00:00.000")),0,
IF( AND(start_time__c < TIMEVALUE("05:00:00.000") ,end_time__c >= TIMEVALUE("22:00:00.000")) , (( TIMEVALUE("05:00:00.000") -start_time__c ) + (end_time__c - TIMEVALUE("22:00:00.000")))/3600000,
IF( AND(start_time__c < TIMEVALUE("05:00:00.000") ,end_time__c < TIMEVALUE("22:00:00.000")) , ( TIMEVALUE("05:00:00.000") -start_time__c )/3600000,
IF( AND(start_time__c >= TIMEVALUE("05:00:00.000") ,end_time__c >= TIMEVALUE("22:00:00.000")),(end_time__c - TIMEVALUE("22:00:00.000"))/3600000,
0)))),

IF( AND(start_time__c >= TIMEVALUE("22:00:00.000") ,end_time__c <= TIMEVALUE("05:00:00.000")),(end_time__c -start_time__c )/3600000 ,
IF( AND(start_time__c < TIMEVALUE("22:00:00.000") ,end_time__c <= TIMEVALUE("05:00:00.000")), (end_time__c - TIMEVALUE("22:00:00.000") )/3600000 ,
IF( AND(start_time__c >= TIMEVALUE("22:00:00.000") ,end_time__c > TIMEVALUE("05:00:00.000")),(TIMEVALUE("05:00:00.000") -start_time__c )/3600000 ,

7)))

時間項目の計算について

1
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
1
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?