Multiple Columns to Change to Time format

Continuing the discussion from Time Format Convert in Linq:

Hi @Yoichi

i have one issue…

Three day back you share one code… in that code you have to pass the single columns Name…

in case pass many columns. Where i have to change ?..

Thanks
Shyam

Hi,

Can you try as the following?

Dim cols As String() = {"Time","Time2"}
dt.AsEnumerable.ToList.ForEach(Sub(r)
    cols.ToList.ForEach(Sub(c)
        If DateTime.TryParseExact(r(c).ToString,{"%H","H:m","H.m","h.m tt"},System.Globalization.CultureInfo.InvariantCulture,System.Globalization.DateTimeStyles.None,New DateTime) Then    
            r(c)=DateTime.ParseExact(r(c).ToString,{"%H","H:m","H.m","h.m tt"},System.Globalization.CultureInfo.InvariantCulture,System.Globalization.DateTimeStyles.None).ToString("HH:mm")
        Else
            r(c)="00:00"
        End If
    End Sub
    )
End Sub
)

Regards,

Hi @Yoichi

Thanks :slight_smile:

1 Like

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