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

日時型の変数をDATEVALUEで変換した時のローカル時間の扱い

Last updated at Posted at 2022-09-16

日時型をTEXT関数で変換すると GTM表示されます。
しかしDATEVALUE関数はGTMでなくローカルタイムゾーンで評価されるようです。

上は日時型をDATEVALUEで変換したもの
下は日時型をTEXTで変換したもの

image.png

IF( IsAcquiredDuringDaylightSavings__c, 

AND( 
WEEKDAY(DATEVALUE(AcquisitionDatetime__c )) != 1, 
WEEKDAY(DATEVALUE(AcquisitionDatetime__c )) != 7, 
TIMEVALUE(AcquisitionDatetime__c + (11 / 24)) >= TIMEVALUE("08:30:00.000"), 
TIMEVALUE(AcquisitionDatetime__c + (11 / 24)) <= TIMEVALUE("17:30:00.000") 
), 

AND( 
WEEKDAY(DATEVALUE(AcquisitionDatetime__c )) <> 1, 
WEEKDAY(DATEVALUE(AcquisitionDatetime__c )) <> 7, 
TIMEVALUE(AcquisitionDatetime__c + (10 / 24)) >= TIMEVALUE("08:30:00.000"), 
TIMEVALUE(AcquisitionDatetime__c + (10 / 24)) <= TIMEVALUE("17:30:00.000") 
) 

) 

Acquired during business hours formula

DATETIMEVALUEを使った時の時間(ローカル? GMT?)

普通に日付フィールドにした場合はちゃんと日本時間

TEXT(datetime_1__c) + ":" + TEXT(datetime_2__c) + ":" + TEXT(datetime_1__c - datetime_1__c)

2022-07-09 03:15:00Z:2022-07-08 03:00:00Z:1.01041666666666666666666666666666666667

DATETIMEVALUEを使ったらGMTになっていますねぇ。

TEXT(datetime_1__c) + ":" + TEXT(DATETIMEVALUE("2022-07-08 12:00:30")) + ":" + TEXT(datetime_1__c - DATETIMEVALUE("2022-07-08 12:00:30") )

2022-07-09 03:15:00Z:2022-07-08 12:00:30Z:.635069444444444444444444444444444444444

もしかして、+09:00が必要かな。

TEXT(datetime_1__c) + ":" + TEXT(DATETIMEVALUE("2022-07-08T12:00:30+09:00")) + ":" + TEXT(datetime_1__c - DATETIMEVALUE("2022-07-08T12:00:30+09:00") )

これでは何も表示されません。

TEXT(datetime_1__c) + ":" + TEXT(DATETIMEVALUE("2022-07-08 12:00:30+09:00")) + ":" + TEXT(datetime_1__c - DATETIMEVALUE("2022-07-08 12:00:30+09:00") )

image.png

Looks like there's a problem.

Unfortunately, there was a problem. Please try again. If the problem continues, get in touch with your administrator with the error ID shown here and any other related details.

ui.services.connection.api.PartnerConnectionException: UNKNOWN_EXCEPTION: An unexpected error occurred. Please include this ErrorId if you contact support: 772115904-244412 (1814626073)

数式 (テキスト)で2つの日付/時間型項目の差異を秒数まで表示したい場合

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