24:00:00をDateTime変数に代入する方法

UiPath Studio Community Edition 23.8.1版を利用中の初心者です。

1.やりたいこと

ログをExcel出力するxamlファイルを作成したため、その中でProject実行開始とProject実行終了までかかった時間の差分をDateTime関数で計算したいと考えています。

2.悩んでいること

下記の構文でDateTime変数 dat_3に差分が入ることを期待していますが、24:00:00をDateTime変数に代入する方法が分かりません。
有識者の方、アドバイスをお願致します。

For Each Rowアクティビティでログ情報の入ったDataTableを回す際に、

Index=765のときに、

dat_1 = CDate(Row(“TimeStamp”)) '------dat_1には"HH:mm:ss"の値が入る想定です。

Index=790のときに、

dat_2 = CDate(Row(“TimeStamp”)) '------dat_2には"HH:mm:ss"の値が入る想定です。

Else Ifアクティビティで

dat_2 > Dat_1の場合は、
Then
dat_3 = dat_2 - dat_1
Else
dat_3 = dat_2 + (24:00:00-dat_1)

Hi @gorby

Try the below way if you want the difference between the execution start time and execution End Time:

Assign -> dat_1= Now
Assign -> dat_2 = Now
Assign -> dat_3= dat_2-dat_1
Log Message -> dat_3.ToString("hh\:mm\:ss")

Note: dat_1 and dat_2 are of DataType System.DateTime and dat_3 is of DataType System.TimeSpan

Check the below workflow for better understanding:

Hope it helps!!

Thank you for your reply!
One Question for you.

1.When I extract “HH:mm:ss” from “yyyy/MM/dd HH:mm:ss”,
Can I use next syntax? Or Should I convert object type variable Row(“TimeStamp”)) to String type variable first?

dat_1 = CDate(Row(“TimeStamp”))(“HH:mm:ss”)

Hi @gorby

Try this:

dat_1 = CDate(Row("TimeStamp")).ToString("HH:mm:ss")

Regards

Hi your suggested following syntax raised syntax error…(See the attached png file)
Hope your confirmed suggestion.

dat_1 = CDate(Row(“TimeStamp”)).ToString(“HH:mm:ss”)

Try this way:

dat_1= CDate(Row(“TimeStamp”))

dat_1 will be of DataType System.DateTime and you can use the provided syntax to find the difference between excecution time.

Regards

Hi, Each of your suggested following syntax raised syntax error…(See the attached png file)
Hope your confirmed suggestion.

dat_3.ToString(“HH:mm:ss”)
dat_3.ToString(“hh:mm:ss”)
dat_3.ToString(“hh\:mm\:ss”)

dat_1

Hi I noticed the following syntax doing well by myself.
Thank you anyway!

dat_3.ToString

Hello @gorby
You can use the Timer Activity to find the Process time duration.

  1. Use Start timer at Begining of the Process and assign the Variable. —>Timer1
  2. Use the Stop Timer Activity and use same varible used for Start Timer. —> Timer1
  3. Print the Log messgae —> Timer1.Elapsed.Duration.ToString
    image

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.