How to trim this string to get actual date time format?

Hello
My input is having the below format

input
2024-09-20 06:32:26.3603377
2024-09-20 06:33:39.4063317
2024-09-20 06:34:26.11096

i want my output like below
2024-09-20 06:32:26
2024-09-20 06:33:39
2024-09-20 06:34:26

basically need to trim that value after dot. PLEASE HELP ASAP

Thanks in advance

Hi @Venu_V

Try this

Code:

For Each row As DataRow In DT.Rows
    row("DateColumn") = row("DateColumn").ToString().Split("."c)(0)
Next

Regards,

Hi @Venu_V,
Try with this:
System.Text.RegularExpressions.Regex.Replace(yourInput, “.\d+$”, “”)

@Venu_V

If your input is in string try like below

Input.Split(".")(0)

Regards,

thank you very much it worked.

1 Like

Hello @Venu_V

I would split the string and take index 0.

Assuming this is in a datatable, I would use:

For each row
Assign str_date = row("date").ToString.Split(".")(0)

Regards
Soren

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