Actually when we need date time value in specific format like (dd/mm/yyyy) or in other  format,  while we are using datetime as a string variable.

In this case it becomes a little bit typical to change string variable value to a specific format. So here we need to change our string variable value to a specific datetime format after that change it to a format you want to change



Parse ‘strExpiryDateTo’ string into proper date time format in which string is already.

‘dtStrExpiryDateTo’ variable which is storing datetime parsed value change it to a particular format you want to change. In this case it is changing in (“mm/dd/yyyy”) format.


DateTime dtStrExpiryDateTo = DateTime.ParseExact(strExpiryDateTo, “mm/dd/yyyy”, null);

strExpiryDateFrom = dtStrExpiryDateTo.ToString(“mm/dd/yyyy”);

Leave a comment

Your email address will not be published. Required fields are marked *