Hi UiPath,
I’m facing a difficult problem with my project.
Let say I have the sample Excel file below:
My goal is to filter out the rows with current week using “Created on” column.
Hope someone can help me
Thanks!
Alvin
Hi UiPath,
I’m facing a difficult problem with my project.
Let say I have the sample Excel file below:
My goal is to filter out the rows with current week using “Created on” column.
Hope someone can help me
Thanks!
Alvin
Use the below syntax
((CreatedOn_Variable.Date >= DateTime.Today.AddDays(-(CInt(DateTime.Today.DayOfWeek))) AndAlso CreatedOn_Variable.Date <= DateTime.Today.AddDays(6 - CInt(DateTime.Today.DayOfWeek))))
Hope it help!!
dtFilteredData
.dtInputData
.DateTime.Parse(row("Created on").ToString()).Date >= GetFirstDayOfWeek(DateTime.Today) AndAlso DateTime.Parse(row("Created on").ToString()).Date <= GetLastDayOfWeek(DateTime.Today)
dtFilteredData
DataTable using the Add DataRow activity.Hey @alvin.c.apostol26 , Try the below code
dtInput.As.Enumerable.Where(Function(row) row("Created On) < DateTime.Now.AddDays(-1*(7 + (DateTime.Now.DayOfWeek - DayOfWeek.Monday)) mod 7).Date.ToString("MM/dd/yyyy") or row("Created On) > DateTime.Now.AddDays(1*(7 + (DateTime.Now.DayOfWeek - DayOfWeek.Monday)) mod 7).Date.ToString("MM/dd/yyyy"))
This will give dates other than the current week days if you week starts from Monday and ends at Sunday
Please try this
dtInput.As.Enumerable.Where(Function(row) row("Created On") < DateTime.Now.AddDays(-1*(7 + (DateTime.Now.DayOfWeek - DayOfWeek.Monday)) mod 7).Date.ToString("MM/dd/yyyy") or row("Created On") > DateTime.Now.AddDays(1*(7 + (DateTime.Now.DayOfWeek - DayOfWeek.Monday)) mod 7).Date.ToString("MM/dd/yyyy"))
Sorry for the error generated, try using the below code
dtInput.AsEnumerable.Where(Function(row) row("Created On").ToString < DateTime.Now.AddDays(-1*(7 + (DateTime.Now.DayOfWeek - DayOfWeek.Monday)) mod 7).Date.ToString("MM/dd/yyyy") or row("Created On").ToString > DateTime.Now.AddDays(1*(7 + (DateTime.Now.DayOfWeek - DayOfWeek.Monday)) mod 7).Date.ToString("MM/dd/yyyy"))