Nullable Datetime Value added in linq

Hi Team,

How to Add Nullable Closed Date Columns in linq code with this Datatype.

input:

image

Code linq:

(From row In Dt_Excel.AsEnumerable()
Select dt_Result.LoadDataRow(New Object(){
(row.Field(Of Object)(“Ticket ID”)),
(row.Field(Of Object)(“Date”)),
(row.Field(Of Object)(“Closed Date”)),
(row.Field(Of Object)(“Journey Cycle”)),
(row.Field(Of Object)(“Quarter”))
},True)).CopyToDataTable

Error :
image

Can tell how to fix this issue.

Thanks
Shyam

Hi,

How about the following expression?

(From row In Dt_Excel.AsEnumerable()
Select dt_Result.LoadDataRow(New Object(){
(row.Field(Of Object)("Ticket ID")),
(row.Field(Of Object)("Date")),
If(row.Field(Of Object)("Closed Date") Is Nothing OrElse String.IsNullOrEmpty(row.Field(Of Object)("Closed Date").ToString),Nothing,row.Field(Of Object)("Closed Date")),
(row.Field(Of Object)("Journey Cycle")),
(row.Field(Of Object)("Quarter"))
},True)).CopyToDataTable

Regards,

1 Like

Hi @Shyam_Pragash ,

Could you check with the below Expression :

(From row In Dt_Excel.AsEnumerable()
Select dt_Result.LoadDataRow(New Object(){
row("Ticket ID"),
row("Date"),
row("Closed Date"),
row("Journey Cycle"),
row("Quarter")
},True)).CopyToDataTable

Let us know if you still have issues.

Also do check the Datatable value in Debug Panel and confirm on what values are present in Closed Date column.

1 Like

Hi @Yoichi

Thanks it work fine…

@supermanPunch

unwanted words are remove… Thanks

Thanks
Shyam

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.