From d in invoicesDT.AsEnumerable
Let dp = DateTime.ParseExact(d("initial date").toString,"dd/MM/yyyy",System.Globalization.CultureInfo.InvariantCulture).ToString("dd/MM/yyyy")
Where dp = now.AddDays(-1).Date
Select r = d).ToList
(From d In Dt1.AsEnumerable
Let dp = DateTime.ParseExact(d("initial date").toString,"dd/MM/yyyy",System.Globalization.CultureInfo.InvariantCulture).ToString("dd/MM/yyyy")
Where dp = DateTime.Now.AddDays(-1).ToString("dd/MM/yyyy")
Select r = d).ToList
Thanks Paul, yes, the problem are some hide rows blank and other with some random value (“TOTAL”), how can i remove all the row from the expression except for the Date?
This is a good reason why it would be better to do this with activities. Then you could use a Try/Catch to handle if the “initial date” value isn’t parseable.
I grasped the point of managing it via activities and the for each row. I always thought that linqs were more efficient than the for each row approach.
I have read the guide peter, one thing is not clear to me.
Once you have analysed the excel file, and since the date is read in this format “dd/MM/yyyy” you apply what is written in the guide.
If one day the way the date is read changes (because it changes within the excel file) and it becomes MM/dd/yyyyy, how do you deal with that?
I have seen the approach of using the various date formats within the array. But if for example you have this date 05/04/2022, even handling it via an array, how do you distinguish between 5th of April and 4th of May?
The expression will use the first format that matches.
So if your formats are {“MM/dd/yyyy”,“dd/MM/yyyy”} you’ll get May 4 2022. If you switch them around to {“dd/MM/yyyy”,“MM/dd/yyyy”} then you’ll get April 5 2022.