Regex to convert yyyymmdd to dd/mm/yyyy

@loginerror @srdjan.suc any suggestion pls?

Hi have a datatable with column somedate.

the values in this column is 20190830,i want to use a regex to change date format to “dd/mm/yyy” for the entire column.

i am looping through the datatable and inside for each row:
row(“sonedate”) i get value 20190830.

Any suggestion what is the best way to convert it to 30/08/2019.

Best Regards

1 Like

Hi @ANSHUL
Instead ofconverting yyyymmdd to dd/mm/yyyy

CDate(row(“sonedate”).ToString(“dd/mm/yyyy”))

Thanks
Ashwin S

1 Like

Already tried, getting this error
image

@ANSHUL

Try Below one:

   row("sonedate") = Datetime.parseexact(row("sonedate").ToString,“yyyyMMdd”,system.globalization.cultureinfo.invariantculture).tostring(“dd/MM/yyyy”)
2 Likes

You can try this one @ANSHUL

Imports System
Dim strDate = “20190830”
Dim dateVal3 As DateTime
Dim outputStr As String
If Date.TryParseExact(strDate, “yyyyMMdd”, System.Globalization.CultureInfo.GetCultureInfo(“en-US”), System.Globalization.DateTimeStyles.None , dateVal3) Then
outputStr = dateVal3.ToString(“dd/MM/yyyy”)
Console.WriteLine(outputStr)
Else
Console.WriteLine(“‘{0}’ is not in an acceptable format.”, strDate)
End If

@ANSHUL

Use Assign activity and try above expression. It should be inside ForEach Row activity.

row(“sonedate”) = Datetime.parseexact(row(“sonedate”).ToString,“yyyyMMdd”,system.globalization.cultureinfo.invariantculture).tostring(“dd/MM/yyyy”)

5 Likes

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