How to adjust dates

Please assist so i have refreshable file like this,


after changing financial period on j3 the data refreshes so after that i need to read commission tab which looks like this…so the bot runs every Tuesday now the issue is i need assistance if Tuesday falls on the 28 or 29 i need to add cashupperiodID for the next month

i used this to filter the cashupperiodID filteredcolumns=If(dtCommission IsNot Nothing AndAlso dtCommission.Rows.Count > 0,
dtCommission.AsEnumerable() _
.Where(Function(row) row.Field(Of String)(“TopLevelCode”).Contains(“464”) AndAlso
CLng(row.Field(Of String)(“CashUpPeriodID”)) > CLng(PreviousCashupID)) _
.OrderBy(Function(row) CLng(row(“CashUpPeriodID”))) _
.CopyToDataTable(),
dtCommission.Clone())

So here our previous CashupperiodID was 1202603028 so we added cashupperiodID for last month and this month

Hello @pabaleloh Used LLM for the code and it is not tested but give it a try inside Invoke code activity

Dim today As DateTime = DateTime.Now
Dim MaxCashupID As Long

If today.DayOfWeek = DayOfWeek.Tuesday AndAlso (today.Day = 28 OrElse today.Day = 29) Then
Dim nextMonthPeriod As String = today.AddMonths(1).ToString(“yyyyMM”)
MaxCashupID = CLng(“1” & nextMonthPeriod & “99”)
Else
Dim currentMonthPeriod As String = today.ToString(“yyyyMM”)
MaxCashupID = CLng(“1” & currentMonthPeriod & “99”)
End If

If in_dtCommission IsNot Nothing AndAlso in_dtCommission.Rows.Count > 0 Then
out_filteredcolumns = in_dtCommission.AsEnumerable() _
.Where(Function(row)
Dim currentID As Long = CLng(row.Field(Of String)(“CashUpPeriodID”))
Return row.Field(Of String)(“TopLevelCode”).Contains(“464”) AndAlso
currentID > CLng(in_PreviousCashupID) AndAlso
currentID <= MaxCashupID
End Function) _
.OrderBy(Function(row) CLng(row(“CashUpPeriodID”))) _
.CopyToDataTable()
Else
out_filteredcolumns = in_dtCommission.Clone()
End If

and ensure your arguments like

in_dtCommission direction In and type System.Data.DataTable and pass value your input DataTable
in_PreviousCashupID direction In of type String and pass your variable holding the last ID
then out_filteredcolumns direction Out and of type System.Data.DataTable then pass your output DataTable

Cheers

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