Date Format Errooor

Good day everyone,

I am trying to change the date format from yyyy/mm/dd to yyyy-mm-dd from this:


TO:
image

In my flow I am using this to format the ReceiptDate which is yyyy/mm/dd on the first screenshot :

image

It is suppose to take the exact date as this and just change the slash ‘/’ to ‘-’:
image

But the results are totally different check below:

Can someone assist please

Hi @Anelisa_Bolosha1

Just change the below expression to,

DateTime.parseexact(ReceiptDate.toString, "yyyy/MM/dd", System.globalization.Cultureinfo.InvariantCulture).toString("yyyy-MM-dd")

m should be capital for months.

Hope it helps!!

It worked, thanks so much @mkankatala .

Very helpful.

Cheers

1 Like

Quick and dirty:
since you convert from string → string, and the only ‘date’ component is your own interpretation of the data, you might as well have done this:

Assign RecipientDate2 = RecipientDate.Replace(“/”, “-”)

If RecipientDate is in a DateTime format to start with (since you felt the need to add .toString) you could have done the direct transformation by this:

Assign RecipientDate2 = RecipientDate.ToString(“yyyy-MM-dd”)

Note that mm indicates minutes, and MM months.

1 Like

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