I have a problem with the DateTimePicker. I am new to C# and developing a standalone application with MS Access 2007 as my DB.
I have a DateTimePicker (dtp_btime) with Format as “Time” and Custom Format “hh:mm tt”.
No doubt it can display as “10:30 pm”. But when I click on save it obviously saved both the Date and Time in the DB table.
cmd.CommandText = "insert into Booking(cname, bdate, btime, ccontact, sname) Values('" + txt_cname.Text + "','" + dtp_bdate.Value.Date + "','" + dtp_btime.Value + "','" + txt_ccontact.Text + "','" + txt_sname.Text + "')";
How can I only save the time without the date from the DateTimePicker?
If it’s a text field in access, you should be able to use
If it’s not, then just store date and time as-is and display just the time portion in your reports or wherever it’s displayed.