How to Convert multiple column date format in data table using linq(With out foreach)

I want to convert particular column date value format in data table with out for each. Can anyone help me on this…?

Hi @BalaM1510,

Welcome to the Forum

you can try this way

  1. Do the Linq query part and take the result you will eventually use that result right.
  2. When you using the result do the Date Conversion part using
    DateTime.Parse method

As my understanding you cant directly do the update part

@BalaM1510
the main building block is an array with formats:

which can be used
DateTime.ParseExact(YourDateString, arrFormats, YourCultureInfo, DateTimeStyles.None)

from your question it can be derived:

  • a column with date strings is the input for a dateTime.ParseExact
  • the conversion result will update the value within the column

LINQ could be used for this. But as we have to be prepared for conversion fails LINQ is less helfull for this due:

  • ALL or Nothing is converted
  • intransparent Issue tracing
2 Likes