Pages

Saturday 15 September 2012

How to convert a date in "dd/MM/yyyy" format to a DateTime variable "MM/dd/yyyy" format in ASP.Net?

Suppose, we have a date field (Let say "Joining Date") in dd/MM/yyyy and you want to convert it into  DateTime variable, then the following lines will help you to do so.

string DateofJoining = "25/08/2010";
System.Globalization.DateTimeFormatInfo dtformat
= new System.Globalization.DateTimeFormatInfo();
dtformat.ShortDatePattern = "dd/MM/yyyy";
DateTime dtJoiningDate = DateTime.Parse(FromDate, dtformat);

This will convert the string value into datetime("08/25/2012 12:00:00 AM").


Regards,
Prajanuranjan....

No comments:

Post a Comment

Total Pageviews