Skip blank values in Invoke code convert date code

Morning All,

Hoping someone can help me with a date format question. I’m using the invoke code to convert the dates from a table prior to writing out a delimited file. I’ve used the below code for the past year with no issues. I’ve recently started getting blanks in the data. How can I modify the below code to skip blank “Effective Date” values?

Using Invoke Code - CleanTable.AsEnumerable().ToList().ForEach(Sub(row)row(“Effective Date”)=DateTime.ParseExact(row(“Effective Date”).ToString,“MM/dd/yy hh:mm tt”,System.Globalization.CultureInfo.InvariantCulture).ToString(“yy-MM-dd hh:mm:ss”))

HI @jsilvestre

You can try like this

Hope This Helps

Regards
Sudharsan

Thank you but I don’t want to remove the records from the table.

Check with this code

CleanTable.AsEnumerable().ToList().ForEach(Sub(row) row(“Effective Date”)=if(String.IsNullOrEmpty(row(“Effective Date”).Tostring),"",DateTime.ParseExact(row(“Effective Date”).ToString,“MM/dd/yy hh:mm tt”,System.Globalization.CultureInfo.InvariantCulture).ToString(“yy-MM-dd hh:mm:ss”)))

Regards
Sudharsan

1 Like

Thank you!!!

1 Like

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