hello i would like to put a format date from uipath, if before read the excel only 1 colum change the value to short date after to save in the data table
Hi Buddy,
you can use Tostring() to format the date variable.
Ex. Today.ToString(“dd-MM-yyyy”)
Datetime.ParseExact(“24/12/2021”,“dd/MM/yyyy”,System.Globalization.CultureInfo.InvariantCulture)
use lower case ‘d’ for day
dd: 08
ddd: Tue
MM: 04
MMM: APR etc
Cheers buddy.
#MarkSolution-if-itWorksForYou.
ok but if i had a dates like this
but there are data general i want to change in the same excel to format date short
Hey,
try this:
DateTime.Now.ToString(“dd.MM.yyyy”)
or for string
Datetime.ParseExact(stringDate,“dd.MM.yyyy”,System.Globalization.CultureInfo.InvariantCulture)
Hi
First I would like you to check the date format you are getting once after reading the excel with Read Range activity
-
So use a read range activity and get the output as dt
-
Now use a simple writeline activity and mention like this
dt.Rows(0)(“date columnname”).ToString
This will show the date and it’s format in output panel
-
Use a FOR EACH ROW activity and pass dt as input
-
Inside the loop use a assign activity like this
Choose any of the below expression based on the date and date format you are getting
If the format is like this
16/12/2021 00:00:00
Then assign activity will be with this expression
CurrentRow)”date ColumnName”) = Datetime.ParseExact(CurrentRow(“date ColumnName”).ToString.SubString(0,10).Trim,“dd/MM/yyyy”, System.Globalization.CultureInfo.InvariantCulture).ToString(“dd.MM.yyyy”)
If the format you see in writeline is like this
16.12.2021 00:00:00 or just 16.12.2021
Then assign activity will be with this expression
CurrentRow)”date ColumnName”) = Datetime.ParseExact(CurrentRow(“date ColumnName”).ToString.SubString(0,10).Trim,“dd.MM.yyyy”, System.Globalization.CultureInfo.InvariantCulture).ToString(“dd.MM.yyyy”)
Note; you can get to any format you want by mentioning that atlast in .ToString(“date format”)
Cheers @VAZQUEZ_SOSA_LUIS_ALBERTO
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.