I have a table in Excel with a SpentTime column that looks like this
The shape of the column is general (hh:mm:ss), and a value of one row 0:01:04for example. By copying the table to a separate sheet the column value is 0.000740740740740741 and it looks like this,
how can I add up and calculate the total time from all rows for the entire table without a loop for each? I have rows with no values
- While reading data check preserve format.
- To add the data create a sum variable outside loop:
Something like this:
- Inside the loop
use timesp=TimeSpan.Parse(row(“SpentTime”).toString).Add(timesp)
that should work!
and as @ppr Suggested:
You can simply read the data without checking preserve format.
Use the loop:
inside the loop you can write an assign activity:
timesp=TimeSpan.Parse(DateTime.FromOadate(row(“SpentTime”).toString).TimeOfDay).Add(timesp)
Thanks and Happy Automation!
'row is not declared.I don’t want to use a cycle for each
Have a look as LINQ could be an alternate option
and use loop for each returns error … conversion from String to Double, assuming that the timespan variable is of type timespan
Here TimeSpan is not a variable, timesp is a variable with timeSpan DataType
a variable timesp of type timespan returns an error … Conversion Fromm String to Double