Date conversion format

I want to convert 29 Aug 2017 to DD/MM/YYYY IN UI PATH.can anyone help me out?

HI @krishnan,

Refer this link

use this code

DateTime.ParseExact(strValue.ToString(),"dd MMM yyyy",Globalization.CultureInfo.InvariantCulture).ToString("dd/MM/yyyy")

Arivu :slight_smile:

I had put the below code in ASSIGN ACTIVITY.
str_date = DateTime.ParseExact(29 Aug 2017.ToString(),“dd MMM yyyy”,Globalization.CultureInfo.InvariantCulture).ToString(“dd/MM/yyyy”)

I am getting error saying String was not recognized as a valid Date Time.can you help on ity?

Hi @krishnan

Use this code
str_date = DateTime.ParseExact("29 Aug 2017","dd MMM yyyy",Globalization.CultureInfo.InvariantCulture).ToString("dd/MM/yyyy")

Arivu :slight_smile:

when I run, I get the converted date as 29/00/ should be 29/08/2017
can you help?

can you reply ASAP ?

Can you check again i am getting exact answer.

Arivu :slight_smile:

I got it.thanks for your help.

I can only get your code to work with a Hardcoded Date. I need the date part to dynamic. Specifically I need it to calculate Yesterday’s Date. Can you help?

I’m not sure I understand your question?

The date (in this case 29 Aug 2017) should be a string variable. In your program is Yesterday’s date a string variable? If so, just replace “29 Aug 2017” with the name of your variable instead.

If you want yesterdays date to be a string in that format then instead you should use Today.AddDays(-1).ToString("dd/MM/yyyy")

@Dave ~ The second part of your post is the answer I was looking for. Thanks.