Hello everyone.
i have a little problem.
I want insert a single date in “type to” from excel file.
this is my example
this is my excel file
when I start the automation the result is
how can I change from “04/28/2020 00:00:00” to “28/04/2020”?
i think with assign activy but I don’t know how.
thanks a lot!
loris
Thom_Co
(Thomas Cowles)
April 29, 2020, 2:58pm
2
Try gironi.ToString(“dd/MM/yyyy”)
The reason for what you see is because the data is being show in the raw DateTime format. The .ToString part helps to format the date to what you want.
directly in a message box on into assign activity?
Thom_Co
(Thomas Cowles)
April 29, 2020, 3:02pm
4
Either should be fine. Based on the screenshot above, I assumed it would be within the message box activity.
Hi @Loris_Sambinelli ,
Can you try below code:
Convert.ToDateTime(giorni).ToString(“dd.MM.yyyy”)
Thom_Co
(Thomas Cowles)
April 29, 2020, 3:15pm
7
Aah! Didn’t realise you wanted to change the format.
Change your variable from generic to DateTime, then use the below code in an assign activity.
Datetime.ParseExact(gironi,“dd/MM/yyyy”,system.globalization.cultureinfo.invariantculture).ToString(“dd.MM.yyyy”)
I’m assuming it is a format conversion as your excel has the date format as dd/MM/yyyy
Thom_Co
(Thomas Cowles)
April 29, 2020, 3:27pm
9
This one - mscorlib [4.0.0.0] > System > DateTime
no. i have a this problem
Error ERROR Validation Error Compiler error(s) encountered processing expression “Datetime.ParseExact(giorni,“dd/MM/yyyy”,system.globalization.cultureinfo.invariantculture).ToString(“dd.MM.yyyy”)”.
Option Strict On non consente conversioni implicite da ‘Date’ a ‘String’. dabuttare1.xaml
Thom_Co
(Thomas Cowles)
April 29, 2020, 5:26pm
11
The reason is not working is because you’re putting a string back into a DateTime variable (should have spotted that initially, sorry!).
Keep your DateTime variable, but have a new string variable to assign that code too. Then it should hopefully work.
Hi @Loris_Sambinelli ,
Just try keeping the type of the cell B1 as text .
Then run the process, that should help you get the same format as in excel.
Let me know for any queries
tdhaene
(tom Dhaene)
April 29, 2020, 6:39pm
13
Change giorni to giorni.tostring in the answer of thom_co ciao!
thanks people but i cant’ do it.
Its’ impossibile for me to modify the cell on excel from result of a formula to text because that date change everyday.
i don’t understand what to do nowbecause if I follow @tdhaene
whit this is code
Datetime.ParseExact(giorni.ToString,“dd/MM/yyyy”,system.globalization.cultureinfo.invariantculture)
i have this problem
String was not recognized as a valid DateTime.
and i don’t understand what do he tell me @Thom_Co
sorry but i try to understand this problem.
thanks a lot guys
ciao!
loris
Thom_Co
(Thomas Cowles)
April 29, 2020, 7:45pm
15
I’ll break it down better.
Keep girorni as Datetime.
Set up a new assign with a new string variable called ‘date_message’ (or whatever you fancy).
Have the assign as:
date_message = Datetime.ParseExact(giorni.ToString,“dd/MM/yyyy”,system.globalization.cultureinfo.invariantculture).ToString(“dd.MM.yyyy”)
If you still have problems, you can do gironi.ToString(“dd/MM/yyyy”). Now that gironi is in a DateTime format, it should pick up the formatting now. Make sure to use slashes to play safe.
And if that still doesn’t work, I will let someone else take the reigns.
Thom_Co
(Thomas Cowles)
April 29, 2020, 7:54pm
16
One thing I forgot to add, put ‘date_message’ as the log message output.
@Thom_Co thanks but i can’t go on.
in 1st assign in data message I write:
Datetime.ParseExact(giorni.ToString,“dd/MM/yyyy”,system.globalization.cultureinfo.invariantculture)`
in 2nd assign in giornigiornidiferie.xlsx (10.6 KB) I write
giorni.tostring("dd/MM/yyyy")
I upload my excel file if you want to check
thanks a lot
Hi @Loris_Sambinelli ,
Try the below code:
Datetime.ParseExact(XMLString.ToString,"MM/dd/yyyy hh:mm:ss",System.Globalization.CultureInfo.InvariantCulture).ToString("dd.MM.yyyy")
Your 1st assign is throwing an error because the giorni.ToString is not in “dd/MM/yyyy” format. The ParseExact does not recognize the giorni.ToString in “dd/MM/yyyy” format because in ParseExact, the format you indicate is how the date currently looks like which is “MM/dd/yyyy hh:mm:ss”.
2 Likes
tdhaene
(tom Dhaene)
April 30, 2020, 5:38am
19
Try Datetime.ParseExact(giorni.ToString,“dd/MM/yyyy HH:mm:ss”,system.globalization.cultureinfo.invariantculture) instead.
Maybe the hour format is blocking you.
1 Like
balupad14
(Balamurugan)
April 30, 2020, 7:27am
20
Hi @Loris_Sambinelli ,
This will help you to change the format of the date…
Hi ,
In the release Version 2019.2.0. I have added a new activity called Change Cell Type. It changes the format of the value like below.
[image]
In the Cell Format , can specify the custom format what we have in the excel Like below image.
[image]
Sample : UiPathGoExcel.zip (18.4 KB)
This is the video to configure the package in local.
Here is the link to know about the formats.
Regards
Balamurugan.S
Regards
Balamurugan.S