Problem with a date from excel

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!

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?

Either should be fine. Based on the screenshot above, I assumed it would be within the message box activity.

the result is

where i am wrong?

Hi @Loris_Sambinelli,

Can you try below code:


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.


I’m assuming it is a format conversion as your excel has the date format as dd/MM/yyyy

whic datetime?

This one - mscorlib [] > 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

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 :slight_smile:

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


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


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.

One thing I forgot to add, put ‘date_message’ as the log message output.

@Thom_Co thanks but i can’t go on. :frowning:

in 1st assign in data message I write:

in 2nd assign in giornigiornidiferie.xlsx (10.6 KB) I write

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”.


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

Hi @Loris_Sambinelli,

This will help you to change the format of the date…