String to Date convertion _ Asking your support

Hi everyone.
Have a great day, I am with my brain blocked now…
I extracted a data from a cell in Excel, and convert it to string, after Split it, catch the date (then discard the time info) and save it in the origin cell. That works fine.
But, I need to add a column with the MONTH in string for filtering. Then I need to read the last cell (in string format: dd/MM/yyyy) and convert to MONTH (string better). I think I can do this using a Dictionary variable or only using the month number, but I do not know the sentence to type into the assign activity.
regards.

Dt.Select(“Started '” & DateTime.now.ToString(“MM”) & "’ ").CopyToDataTable

Hope this helps you!!!

Good day

@aldo.zegarra Is your Date in this Format dd/MM/yyyy always?, If So , then use :
DateTime.ParseExact(yourDateStringInDT,“dd/MM/yyyy”,System.Globalization.CultureInfo.InvariantCulture).ToString(“MM”)

1 Like

Hi.The format is 2/01/2020 00:00:00 MM/dd/yyyy hh:mm:ss.
After first split I have obtained 02/01/2020… that is OK (as string pasted into the cell).
Since that part, I need to obtain the month (01 - January) from that date (now is string-- no more datatime variable).
One solution I found was to split the string using “/” as delimitator… and catch the (1) item . But I would like to take it easier and lighter.
Thanks a lot for your support.

@aldo.zegarra Splitting the String Might be easiest thing if you get in dd/MM/yyyy format always :sweat_smile:. Also What you can try is this :
DateTime.ParseExact(“02/01/2020”,“dd/MM/yyyy”,System.Globalization.CultureInfo.InvariantCulture).ToString(“MM”)