i have a table called as X and this table has a field known as X_DateTime respectively, which has value like 2012-03-11 09:26:37.837.
i want to convert the above datetime value to this format yyyy-MM-dd (2012-03-11) and literally remove the Time (09:26:37.837)
i have used something like below code
DateTimeFormatInfo format = new DateTimeFormatInfo();
format.ShortDatePattern = "yyyy-MM-dd";
format.DateSeparator = "-";
DateTime date = 2012-03-11 09:26:37.837;
DateTime shortDate = Convert.ToDateTime(date , format);
please help me…
i am using C# as my language.
thanks,
You must call
.ToString()method with that format that you want. In your example it will be like this.Or if you want to keep
DateTimetype, you must call.Dateproperty ofDateTimeFrom MSDN