In my excel i have two different columns(Ship 1,Ship 2) with Date values (MM/DD/YYYY) format.
I have used this for Ship 1 “InDT.Select(”[Ship 1] >= ‘#09/05/2021#’ AND [Ship 1] <= ‘#09/28/2021#’“).CopyToDataTable”.It worked without any issues.
For the Ship 2 i have used same code but i am getting error like “The Source contains no DataRows” even though there is a data. I have tried multiple options but didn’t work.
can you help me how to solve this.
No That is not my scenario. Even though dates are available its not filtering those values. its giving error message. i can handle exception scenario. You got my point right?
I have just used only one condition here, you can add multiple And/or as well.
Basically DateTime.ParseExact(“09/05/2021” , “dd/MM/yyyy”, CultureInfo.InvariantCulture) will help us in converting the string value to date time type, but we have to ensure that we specify the correct format as per our input.
In the above example since the date is 09/05/20201 the format used is appropriate I.e., dd/MM/yyyy
Hope this helps, if required I can share the code but will be needing sample date format as per your input.
the code is not working. Error ERROR Validation Error Compiler error(s) encountered processing expression “InDT. AsEnumerable.Where(Function(x) DateTime.ParseExact(x(“Ship Commit 2”).ToString.trim, “MM/dd/yyyy”,CultureInfo.InvariantCulture) >= DateTime.ParseExact(“09/05/2021” , “MM/dd/yyyy”,CultureInfo.InvariantCulture)).CopyToDataTable”.
‘CultureInfo’ is not declared. It may be inaccessible due to its protection level.
‘CultureInfo’ is not declared. It may be inaccessible due to its protection level.
It looks like you’re filtering on dates as strings. That’s not going to give you the desired output, you’re treating them as words and alphabetizing, not treating them as actual date values.
You should convert them to proper datetime values and use the Filter Datatable activity to get what you want.
No. those are the date values same code is working for other column on Dates its filtering and everything is good. Only iam having issue with this column only.
Then the format should be mentioned appropriately as below
InDT. AsEnumerable.Where(Function(x) DateTime.ParseExact(x(“Ship 2”).ToString.trim, "MM/dd/yyyy HH:mm:ss”,system.globalization.cultureinfo.invariantculture ) >= DateTime.ParseExact(“09/05/2021” , “dd/MM/yyyy”,system.globalization.cultureinfo.invariantculture)).CopyToDataTable