I need your help please.
I need to get the date format like 22-11-2021 on Uipath Studio.
Could you please help me?
Welcome to our UiPath community.
Try below expression.
The date format you’ve provided appears to be as follows: “dd-MM-yyyy”.
If you wanted to replicate that for the current date, you could use an Assign activity:
str_CurrentDate = Now.ToString(“dd-MM-yyyy”)
Now, let’s say you have another date, maybe not the “current” date and in a different format such as “MM/dd/yyyy”.
The example date we’ll use is 11/21/2021 and it’s stored as a variable.
str_Date = “11/21/2021”
I can format that date into my preferred format as follows:
str_ReformattedDate = Date.ParseExact(str_Date, “dd-MM-yyyy”, System.Globalization.CultureInfo.InvariantCulture).ToString`
We call the method of a Date class, ParseExact (Date.ParseExact) and pass in the date string, specify the format we want and pass in an InvariantCulture provider and then convert it to a string.