How to update blank values in column which has Datetime As Datatype

Hi Forum, i have a Datatable where one of the columns datatype is System.Datetime but in that column some rows i have update blank values also,
using Linq i’m updating row values as blank it is throwing error due to datatype mismatch.
Even if i give nothing instead of blank(empty string) by default it is reflecting some values in excel like 11100 instead of blank.

how to resolve that using linq or any vb script?

my expression in linq is=(if string.isnullorempty(row(“datecolumn”).tostring),Nothing,cdate((row(“datecolumn”))

NOTE: i don’t want string column type because after writing in excel i cannot apply filter like we do for date type.

@_nithish,

Try this LINQ

row("dateColumn") = If(String.IsNullOrEmpty(row("dateColumn").ToString), DirectCast(Nothing, Nullable(Of DateTime)), CDate(row("dateColumn")))

1 Like

Hi Expert @ashokkarale , thanks for your reply, it is working

1 Like

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