i have column in data table containing yyyyMMdd format which i want to convert in dd-MM-yyyy.
And getting error in following Linq
DT1.AsEnumerable().Select(Function(row) DT1.Rows.Add(DateTime.ParseExact((“DATE_OF_BIRTH”).ToString(), “yyyyMMdd”, System.Globalization.CultureInfo.InvariantCulture).ToString(“dd-MM-yyyy”), True)).CopyToDataTable()
Hi @Lalit_Chaudhari,
This is the correct query you can try:
DT1.AsEnumerable().Select(Function(row)
DT1.Clone().LoadDataRow(
{DateTime.ParseExact(row(“DATE_OF_BIRTH”).ToString(), “yyyyMMdd”,
System.Globalization.CultureInfo.InvariantCulture).ToString(“dd-MM-yyyy”)}, True)
).CopyToDataTable()
Is the column in DateTime format or String?
Follow the below steps to convert the date style by using vb expression,
→ Use the Read range workbook activity to read the excel and store in a datatable called dt.
→ Then use the Invoke code activity, click on edit code and give the below code,
For Each row As datarow In dt.AsEnumerable
row("DATE_OF_BIRTH") = DateTime.ParseExact(row("DATE_OF_BIRTH").ToString, "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture).ToString("dd-MM-yyyy")
Next
→ Click on Edit arguments and give dt in name, select datatable as variable type, select In option in direction dropdown, pass dt variable in value field.
→ Then use the Write range workbook activity to write the datatable to excel.
Hope it helps!!
- Please specify the rror
- Did you check the format from locals panel? If yes then thats correct else it might be that the format is different
- Are there any blank values? If yes then those are to be handled
Cheers
It’s in Number format
Thank you for helping me
already used same approach