//=================Tochange the Date Format
from MM/dd/yyyy to dd/MM/yyyy================//
//First Assign the Date Value to a String Variable
string urDate_Of_Appointment =
TxtDateOfApp.Text;
//Then declare a object of the method of System Define for DateTime Format
System.Globalization.DateTimeFormatInfo
dateDate_Of_AppointmentInfo = new
System.Globalization.DateTimeFormatInfo();
//Then Assign the format of the Date(dd/MM/yyy) to DateTimeFormatInfo
dateDate_Of_AppointmentInfo.ShortDatePattern = "dd/MM/yyyy";
//Then assign the value to variable as per your DateTime Format
DateTime validDate_Of_Appointment = Convert.ToDateTime(urDate_Of_Appointment,
dateDate_Of_AppointmentInfo);
// Assign the value to the class object which we declare Here(Date_Of_Appointment is variable of a object class)
obj.Date_Of_Appointment = validDate_Of_Appointment.ToString();
OR
string RetDateTime(string srcdate)
{
string resdate = "";
try
{
string[] arr = srcdate.Split('/');
if (arr.Length > 0)
{
resdate = arr[2] + "/" + arr[1] + "/" + arr[0];
}
}
catch (Exception)
{
}
return resdate;
}
//Apply in Control
generatex.FrmDate = RetDateTime(FromDate.Text); ;
generatex.ToDate = RetDateTime(ToDate.Text);
Thanks
Satyabrata Behera
OR
string RetDateTime(string srcdate)
{
string resdate = "";
try
{
string[] arr = srcdate.Split('/');
if (arr.Length > 0)
{
resdate = arr[2] + "/" + arr[1] + "/" + arr[0];
}
}
catch (Exception)
{
}
return resdate;
}
//Apply in Control
generatex.FrmDate = RetDateTime(FromDate.Text); ;
generatex.ToDate = RetDateTime(ToDate.Text);
Thanks
Satyabrata Behera
No comments:
Post a Comment