I am confused on formatting date format in a gridview cell from (dd/MM/yyyy H:ss:mm) to (yyyy-MM-dd).
However, I haven't created any column in .aspx-page, but using dynamic binding from SQL to bind result to Gridview datasource. So, adding code which is similar bellowing is not working fine.
<ItemTemplate>
<%#Convert.ToDateTime(Eval("StartDate")).ToString("yyyy-MM-dd") %>
</ItemTemplate>
So, is there any way to changing formatting of the date value?
DateTime
so a simple.ToString("yyyy-MM-dd")
would be enough. – Panagiotis Kanavosdd/MM/yyyy
someone will always enter text in a different format. It might even be you. Once that happens you won't be able to find the incorrect values - what does04/05/2018
mean? – Panagiotis Kanavosdate
ordatetime
, the date values will be retrieved as DateTime values ready for display and formatting – Panagiotis Kanavos