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?

【UiPath】日付型の変数が初期値か確認するには

0
Posted at

結論からいうと、日付型の初期値には01/01/0001 00:00:00が入るため、DateTime.MinValueと比較するのがスマートです。

代表的な変数とその初期値

以下の記事から引用させていただきました。

初期値
String 空文字列("")
Int32 0 (ゼロ)
Boolean false
DateTime 01/01/0001 00:00:00

これらの型の変数は初期値にNull(Nothing)ではなく値が設定されますので、is Nothingで初期値かどうかを比較することはできません。(String型だけは例外的に可能ですが…)
ですので、それぞれの型で初期値かどうか判定するには、String型であればString.Empty""、Int32型などの数字型であれば0と比較して判断する必要があります。

日付型の場合、日付型に設定される最小の値である01/01/0001 00:00:00が初期値として設定されますが、01/01/0001 00:00:00DateTime.MinValueで取得できる値と同じです。タイポや可読性を考えると、日付型の変数が初期値かどうか判定する際はDateTime.MinValueと比較するのがスマートでしょう。

参考

動作環境

UiPath.System.Activities 24.10.7

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?