gorby
(Noteworthy UiPath Forum contributer 2024)
January 1, 2024, 8:32am
1
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)
Parvathy
(PS Parvathy)
January 1, 2024, 9:18am
2
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!!
gorby
(Noteworthy UiPath Forum contributer 2024)
January 1, 2024, 10:36am
3
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”)
Parvathy
(PS Parvathy)
January 1, 2024, 10:39am
4
Hi @gorby
Try this:
dat_1 = CDate(Row("TimeStamp")).ToString("HH:mm:ss")
Regards
gorby
(Noteworthy UiPath Forum contributer 2024)
January 1, 2024, 10:55am
6
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”)
Parvathy
(PS Parvathy)
January 1, 2024, 10:58am
7
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
gorby
(Noteworthy UiPath Forum contributer 2024)
January 1, 2024, 11:21am
8
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”)
gorby
(Noteworthy UiPath Forum contributer 2024)
January 1, 2024, 11:24am
9
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.
Use Start timer at Begining of the Process and assign the Variable. —>Timer1
Use the Stop Timer Activity and use same varible used for Start Timer. —> Timer1
Print the Log messgae —> Timer1.Elapsed.Duration.ToString
system
(system)
Closed
January 4, 2024, 5:06pm
11
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.