Increment Date on diffrent parameters

Hi again friends.

UPDATED!!
In the first i was explaining wrong. Sorry for that.
Now is it correct

I have trided to solve this problem, but i need your help now.

This is an example. I real i have more data and i will explain more about this

ID Date How i want it Time
1 2022-01-01 2022-01-01 00:00
1 2022-01-01 2022-01-01 01:00
1 2022-01-01 2022-01-01 02:00
1 2022-01-01 2022-01-01 03:00
1 2022-01-01 2022-01-01 04:00
1 2022-01-01 2022-01-01 05:00
1 2022-01-01 2022-01-02 00:00
1 2022-01-01 2022-01-02 01:00
1 2022-01-01 2022-01-02 02:00
1 2022-01-01 2022-01-02 03:00
1 2022-01-01 2022-01-02 04:00
2 2022-05-01 2022-05-01 03:00
2 2022-05-01 2022-05-01 04:00
2 2022-05-01 2022-05-01 05:00
2 2022-05-01 2022-05-01 06:00
2 2022-05-01 2022-05-01 07:00
2 2022-05-01 2022-05-02 00:00
2 2022-05-01 2022-05-02 01:00
2 2022-05-01 2022-05-02 02:00
2 2022-05-01 2022-05-02 03:00

My Time Column has value from 00:00 - 23:00

And all this data is hold in data table.

I want to increment the Date every time Column “Time” = 00:00
And when there is a new ID i want it to start from that Date.

I hope its understanble in the example.

I have tried this code below, but that is not working like i want

For Each row in dataTable
If row(“Hour”).ToString = “00”
Assign previousDate = DateTime.Parse(row(“Date”).ToString).AddDays(1)
Else
Assign previousDate = DateTime.Parse(row(“Date”).ToString)
End If
Assign row(“Date”) = previousDate.ToString(“yyyy-MM-dd”)
End For Each

Big thanks

Anders

@Anders_Dahl1

Please try this

  1. For each row in datatable activity and assign a variable to index property in for loop say varindex
  2. If condition with Not varindex.Equals(0) AndAlso currentrow("Time").ToString.Equals("00:00")
  3. On the then side use currentrow("Date") = Cdate(dt.Rows(varindex-1)("Date").ToString).Adddays(1).ToString("MM-dd-yyyy")

Cheers

Hi @Anders_Dahl1

To achieve the desired result of incrementing the date every time the “Time” column is “00:00” and starting from a new date when there is a new ID, you can modify your code as follows:

Assign previousDate as DateTime variable and initialize it with the first row’s date value
For Each row in dataTable
If row(“Time”).ToString = “00:00”
Assign previousDate = DateTime.Parse(row(“Date”).ToString).AddDays(1)
End If
Assign row(“Date”) = previousDate.ToString(“yyyy-MM-dd”)
Next

Thanks!!

Hi @Anil_G
Can you show me how it looks in UiPath with your solution.
I have tried but dont get it.
I also think that Index i great to work with

/Anders

Hi @Nitya1
I updated my problem.
Please check it again.

@Anders_Dahl1

This is how it looks

Hope this helps

cheers

In the loop, check if the current row’s ID is the same as the previous row’s ID and that time equals 00:00. If so, increment the date, else do nothing.