Hi All,
I am trying to get the current date from the input excel and write them to the another excel with the below query,
Input_dt.select(“[Transoft_Processing_Date_Time]like '%”+now.ToShortDateString+“%'”).CopyToDataTable
But getting the error as below,
This is the input excel …where the date column I selecting,
Can I please know how it can be resolved.
Thanks in advance.
ppr
(Peter Preuss)
September 11, 2020, 10:06am
2
it looks like that it takes on the left side the dateTime and on the right side it has the string
give a try on:
Input_dt.select(“[Transoft_Processing_Date_Time] = #”+now.toString()+“#”).CopyToDataTable
the surrounding # indicates that it is a date
https://www.csharp-examples.net/dataview-rowfilter/
sushmitha.e
(Sushmitha E)
September 11, 2020, 10:12am
3
it is saying no data rows.
ppr
(Peter Preuss)
September 11, 2020, 10:43am
4
@sushmitha.e
CopyToDataTable will throw this error when the filter result is empty
it can be handled as by following:
Input_dt.select(“[Transoft_Processing_Date_Time] = #”+now.toString()+“#”).ToList
then check the returned row count similar to
the reason that the filter result is empty can be:
there is no row that is matching the filter expression
there is a problem with the select - just inspect the datatable contents during a debugging
sushmitha.e
(Sushmitha E)
September 11, 2020, 11:04am
5
But today’s date is there in Input Excel…
so, why it is given again the output as no data rows.
ppr
(Peter Preuss)
September 11, 2020, 11:23am
6
Have a look here on another approach, but handling multiple dateformats:
DT_FilterByDate_2Formats.xaml (10.6 KB)
ppr
(Peter Preuss)
September 11, 2020, 9:13pm
8
@sushmitha.e
I had a closer look on it. The time Info confused and it seems that it was blocking the rows.
From the datatable the particular time info was compared with that one from #…+now.toString(… # or 00:00:00 in some scenarios.
dtData.Select(“[Column1] >= #”+now.toString(“MM/dd/yyyy”)+“# And [Column1] <= #”+now.AddDays(1).toString(“MM/dd/yyyy”)+“#”).ToList is working
find demo xaml here:
DTSelect_TodaysDate.xaml (7.4 KB)
Handling the different formats I would say that with the first shared xaml you will have more control on it