Hi,
I have an excel sheet that contains some columns.
We need to Check for “QLD” in state column.
And based on it I need to check the corresponding date and
⦁ If the current day is Tuesday – Friday, filter on current date – 1.
⦁ If the current day is Monday, filter on dates for the last Friday – Sunday
I have attached the excel sheet for the same. Testing_Excel.xlsx (11.2 KB)
I have also attached the screen shot of what the requirement is.
Take an example of todays date and day
Today is Monday so according to the requirement I will have to filter on dates for last Friday to Sunday.
Subtracting the required amount of days
Use For Each Row in Data Table activity to iterate throughfilteredDataTable.
Use assign activty and give the below condition:
currentDate=CDate(CurrentRow("Date").ToString)
DataType of currentDate: System.DateTime
4. Use Else If activity and give the condition:
currentDate.DayOfWeek>=DayOfWeek.Tuesday AndAlso currentDate.DayOfWeek<=DayOfWeek.Friday
Then
currentDate= currentDate.AddDays(-1)
Use Message Box: currentDate.ToString("MM/dd/yyyy")
Else If
currentDate.DayOfWeek=DayOfWeek.Monday
Then
currentDate= currentDate.AddDays(-3)
Use Message Box: currentDate.ToString("MM/dd/yyyy")
Check out the below workflow file. Hope it meets your requirement.
@Kunal_Jain - Did you get a chance to check the workflow that I attached above. Can you please check your data table has a data by printing the rows count
Hi @ushu
I have checked it
It is giving the error at the assign activity
DT.Select(“[State] = ‘QLD’”+“AND [Date] >= #”+PeriodInit.ToString +“# AND [Date] <= #”+PeriodEnd.ToString+“#”).CopyToDataTable.
@ushu And also it must pass all the values present in the excel based on the filter.
I have attached screenshot of what is required in the above thread.
Yes and also need to check the date if state is QLD
And based on it I need to check the corresponding date and
⦁ If the current day is Tuesday – Friday, filter on current date – 1.
⦁ If the current day is Monday, filter on dates for the last Friday – Sunday
For the dates I need to check
If the code running is between Tuesday-Saturday than we have to subtract one day from the date already present in the column.
Example:
Today is 01-08-2023 and day is Tuesday.
Than I need to subtract 1 day from the date mentioned
so date mentioned is
18-07-2023
and subtracting it as it it tuesday
so the day that we will be saving is the datatable is 17-07-2023.
Thanks!!