Problem with converting dates

Hi All, I am trying to type a date into a form. The date is read from Excel so it’s an generic value. In my excel file the format is dd-mm-yyyy but when uipath types it into the form it’s typing mm/dd/yyyy Anyone who knows how to get the dd-mm-yyyy ?
Already tried DateTime.ParseExact(startdatum.ToString,“dd-MM-yyyy”, system.Globalization.CultureInfo.InvariantCulture) but then i get an error "String was not recognized as a valid DateTime.

When i solve this issue i want to use add days in a negative way. So days before de date from my Excel.

Pls can you help me out?

Cdate(dateinstring).tostring(“dd-MM-yyyy”)

3 Likes

try with this buddy @438654
DateTime.ParseExact(startdatum.ToString,“MM-dd-yyyy”, system.Globalization.CultureInfo.InvariantCulture)

Once after this you can add days in negative way like this
DateTime.ParseExact(startdatum.ToString,“MM-dd-yyyy”, system.Globalization.CultureInfo.InvariantCulture).AddDays(-2)

here i have given 2 days from present day
Kindly try this and let know buddy
Cheers @438654

@438654
Cdate(dateinstring).adddays(-2).tostring(“dd-MM-yyyy”)

1 Like

DateTime.ParseExact(startdatum.ToString,“MM-dd-yyyy”, system.Globalization.CultureInfo.InvariantCulture) This one is has the same error “String was not recognized as a valid DateTime”

aaaah sorry buddy try this @438654
DateTime.ParseExact(startdatum.ToString,“MM/dd/yyyy”, system.Globalization.CultureInfo.InvariantCulture).ToString(“dd-MM-yyyy”)
Cheers

did that work buddy @438654

No still the same error. But the other examples with de cdate worked perfectly

3 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.