Convert Date to new format

Hello,

Is there a way to convert a string variable to DateTime variable but in format dd/MM/yyyy?

Here I am converting the string to a date but it outputs in the format of MM/dd/yyyy

image

After you convert to date, then there is no format, you should not worry about it…

When I convert the date and write it to a message box the format is MM/dd/yyyy but I want the format to be in dd/MM/yyyy

@Cormac
Can you provide your sample input date variable

yes, but a date is a date, the format does not matter, that is just a representation of it… if you want to write the date as text is specific format then you use DeadLineDate.ToString("dd/MM/yyyy")

2 Likes

Do you need to use any date calculations on the value?

If not, it sounds like you may just want to leave the value as a string (formatted a a date).

Please try the following:

DateTime.ParseExact(out_TransactionEndDate,”MM/dd/yyyy”,System.Globalization.Cultureinfo.Invariantculture).ToString(“dd/MM/yyyy”)

@Cormac Like bcorrea is saying, the format of a date variable won’t ever change. But we can use a string variable and format it to look like the date you need.

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