I have in a MySQL database with the column type being DateTime the following time:

Timestamp:
9:34:09
9:34:23
9:34:45
9:34:50
9:35:09
9:36:17

But a DataGridView in C# only shows me
9:34
9:34
9:34
9:34
9:35
9:36

Why?

Recommended Answers

try to use Column.DefaultCellStyle.Format property or set it via designer....

Jump to Post

All 3 Replies

Did you check the format of your string?
Format for DateTime strings can be found here.

try to use Column.DefaultCellStyle.Format property or set it via designer....

Solved it with this code:

 try 
            {
                dataGridView1.Columns["Time_Stamp"].DefaultCellStyle.Format = "yyyy-MM-dd hh:mm:ss";

            }
            catch (Exception x)
            {

                MessageBox.Show(x.Message);
            }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.