Date conversion format

studio
variable

#1

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


#2

HI @krishnan,

Refer this link

use this code

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

Regards,
Arivu :slight_smile:


#3

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?


#4

Hi @krishnan

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

Regards,
Arivu :slight_smile:


How to convert the String datatype date value in date("mmddyyyy") format?
#5

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


#6

can you reply ASAP ?


#7

Can you check again i am getting exact answer.

Regards,
Arivu :slight_smile:


#8

I got it.thanks for your help.


#9

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?


#10

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")


#11

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


#12