0

When MYSQl is bind and imported, the time(12:00:00 AM) is also displayed in DateTime.

This code binds to GridView.

MySqlCommand cmd = new MySqlCommand(strqry, conn);
cmd.CommandType = CommandType.Text;
MySqlDataAdapter adapt = new MySqlDataAdapter(strqry, conn);
adapt.Fill(dataTable);
GridView.DataSource = dataTable;
Backs
  • 23,679
  • 4
  • 50
  • 77
K. K
  • 13
  • 4
  • please rephrase it is unclear what your question is, is the problem the different date ranges? what is the problem You experience?? – T. Nielsen Oct 18 '21 at 10:11
  • ```GridView.Columns[1].DefaultCellStyle.Format = "MM/dd/yyyy hh:mm:ss tt";``` use this code to format the datetime for a column. – MD. RAKIB HASAN Oct 18 '21 at 10:13
  • Another option is to format the date in your sql. SELECT DATE_FORMAT(mydate, "%W %M %e %Y") FROM Mytable – Haim Katz Oct 18 '21 at 10:40

1 Answers1

0

In Grid HTML

<asp:Label runat="server" Text='<%# Eval("DateAndTime") %>'

Place "{0:M-dd-yyyy}"

<asp:Label runat="server" Text='<%# Eval("DateAndTime", "{0:M-dd-yyyy}") %>'