0

MYSQL is bind and imported, the time(12:00:00 AM) is also displayed in DateTime. I want to display date without time
Ex) 08-11-22 12:00:00 AM (X)
08-11-22                           (O)

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;
K. K
  • 35
  • 5
  • 1
    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
  • 1
    ```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
  • 1
    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

1

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}") %>'