Question

I set my datetimepicker's value to 1:00 PM or any random hh:mm tt format and insert it into my MSAccess database in a my table with a date/time field. But when my datagridview shows the table, a random "12/30/1899" (+ my input of 1:00 PM). Any idea why this is happening? My code is not here though.

Was it helpful?

Solution

Access Date/Time fields always store both a Date and a Time component. If only a Time value is specified then the Date part defaults to 1899-12-30.

If you want to display just the Time part in a DataGridView column you can set its format to "short time" using something like this (C#, but VB.NET would be very similar):

dataGridView1.Columns[3].DefaultCellStyle.Format = "t";  // short time

OTHER TIPS

it could have been better if you also included your code......

just visit the following link for Date Time Picker information.

DateTimePicker MSDN

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top