0

I have a data grid view that I am populating with a database as its data source. However, the columns with a date as its data type show a date and time while I only want a time.

How do I change the format of a data grid view table?

Private Sub prcDisplayTable()
    dgvViewLecturers.DataSource = Nothing
    dgvViewLecturers.Rows.Clear()
    dgvViewLecturers.Columns.Clear()

    strSQL = "SELECT * FROM Lecturers"
    strTableName = "ViewLecturers"

    daLecturers = New OleDb.OleDbDataAdapter(strSQL, con)
    daLecturers.Fill(dsLecturers, strTableName)

    dgvViewLecturers.DataSource = dsLecturers
    dgvViewLecturers.DataMember = strTableName
End Sub
Pejman Poh
  • 493
  • 2
  • 8
  • 20

2 Answers2

1

try this for time only format

dataGridView1.Columns("dateColumn").DefaultCellStyle.Format = "hh:mm:ss tt";
yogi
  • 19,175
  • 13
  • 62
  • 92
0

Set DefaultCellStyle.Format property.

 dataGridView1.Columns("dateColumn").DefaultCellStyle.Format = "hh:mm:ss t";
KV Prajapati
  • 93,659
  • 19
  • 148
  • 186