My input S.no. date. Value
12/31/2022 24:07:08 AM. 45
03/02/2022. 56
03/28/2022. 78
03/16/2022. 56
03/08/2022. 55
My start date is 03/01/2022 and end date is 03/31/2022. Dates falling between start and end is My output should be
S.no. date. Value
=> Read Range Workbook
Output-> dt
=> Use below syntax in Assign:
Rows = (From row In dt.AsEnumerable()
Let dateString As String = If(row.Field(Of String)("Date").Contains(" "), row.Field(Of String)("Date").Split(" "c)(0), row.Field(Of String)("Date"))
Let dateValue As DateTime = DateTime.ParseExact(dateString, "M/d/yyyy", CultureInfo.InvariantCulture)
Where dateValue >= New DateTime(2022, 3, 1) AndAlso dateValue <= New DateTime(2022, 3, 31)
Select row)
Rows is of DataType IEnumerable(System.Data.DataRow)
=> Use below condition in If
If
Rows.Any()
Assign-> dt_Output = Rows.CopyToDataTable
If
IsNothing(dt_Output) OrElse (dt_Output.AsEnumerable.All(function(x) x.ItemArray.All(function(y) String.IsNullOrEmpty(y.ToString))))'
Then
\\ Do Nothing
Else
Write Range Workbook `dt_Output`
End If
Else
Assign-> dt_Output = New DataTable()
End If
Can you send me the syntax. As if there are no rows it can’t be directly assigned to datatable. So you need to store the that syntax of DataType IEnumerable(System.Data.DataRow) and pass in If condition like if Rows.Any then write it into datatable or create a new datatable.
12/31/2022 24:07:08 AM. 45
04/02/2022. 56
04/28/2022. 78
04/16/2022. 56
04/08/2022. 55
My start date is 03/01/2022 and end date is 03/31/2022. There is no Dates falling between start and end date.my datatable should return as empty row