Problems with the date format

Hi,

I am experiencing a problem with date formatting.
I have a variable that extracts the date of issuance of an invoice of thhe XML in the format 08/28/2019 17:27:24.

I need the date to be in ddMMyyyy format 28082019

My variable is a string

I tried it but it didn’t work

DateTime.ParseExact(dhEmi, “ddMMaaaa”, system.Globalization.CultureInfo.InvariantCulture).ToString

1 Like

Fine
If dhEmi = “08/28/2019 17:27:24”
Then to get as “28-08-2019”

Here you go
dhEmi = DateTime.ParseExact(dhEmi.ToString.Trim,”MM/dd/yyyy hh:mm:ss”,System.Globalization.CultureInfo.InvariantCulture).ToString(“dd-MM-yyyy”)

Now the value of dhEmi will be “28-08-2019”

Cheers @KMota

2 Likes

Hi @Palaniyappan

thanks for the contribution.

Source: Assign

Message: String was not recognized as a valid DateTime.

This error is presented

@KMota You can use this

                                    assign str = "08/28/2019 17:27:24"
                                    assign str = cDate(str).ToString("ddMMyyyy")
3 Likes

Hi @indra,

Thank you, it worked perfectly
:bowing_woman:

1 Like

@Palaniyappan

The example below sent by indra worked fine. Pls take a look :wink: . Thank you very much for your help sir.

assign str = " 08/28/2019 17:27:24
assign str = cDate(str).ToString(“ddMMyyyy”)

1 Like

Great
Cheers @KMota

1 Like

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