How to convert String or Remove symbol

Hi to all,
Usual problem with the strings, which I cannot understand how to use.

i have a problem with string manipulation.
Actually, 2 problems.
1: Conversion of the date.
in my stream i collect the date from a web cloud, and upload file name, and date, to an sql table.
the date for convenience is a varchar value.
image

I have to save this date by removing all symbols, as in example. (“ddMMyyyy_hhmm”)
image

I can’t find a solution

Another small problem, again about text manipulation, is in the collection of the filename.
I noticed that my script fails when the “&” symbol is present in the object name on the Cloud.
When I save in the folder, the symbol will KO the BOT.
How do I replace the & with a - o.

I used this formula to write the name.

“\FilePath”+Gruppo + “” +system.Text.RegularExpressions.Regex.Replace(FileName,“[^a-z A-Z 0-9]”,“”) + " - " + LastMod+ “.pdf”

Thanks A lot!!
Aaron

1 Like

@AaronMark - For your first problem here is the solution using Invoke code method…I guess it should HHmm in your conversion so that it will be in 24 hrs format.

dtSample.AsEnumerable().ToList().ForEach(Sub(row) row(“Changed_Date”)=DateTime.ParseExact(row(“Changed_Date”).ToString,“dd/MM/yyyy HH:mm”,System.Globalization.CultureInfo.InvariantCulture).ToString(“ddMMyyyy_HHmm”))

Build Data Table:

image

Output:

image

  1. I didn’t understood your second issue, if you can brief with sample I can help you with regex.
2 Likes

Use this below code, @AaronMark
CDate(“12/10/2021 06:20”).ToString(“ddMMyyyy_HHmm”)
Hope this may help you :slight_smile:

This seems to be fine, in fact.
Thanks Manish…

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