Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

datetimepicker - setting time 1

Status
Not open for further replies.

696796

Programmer
Aug 3, 2004
218
GB
Hi,

I am using a dateTimePicker to select dates so that they can be used in criteria for a query. The problem i'm having is that when i select a date, the current time comes with it, so when searching on the database if a record has say inserted with a date of 01/01/2006 12:04:33, i may search on the date but it will take the value 01/01/2006 12:36:33(the current time), which means i miss out on my record.

Is there a way to set the time on a date to 00:00:00 and equally on the to date to 23:59:59?

This is the code i use to get my date value into a variable to use with my insert or select statement - btw i am using Access 97.

Dim dDate As Date = dtpDeliveryDate.Text

Many thanks,

Alex
 
You should be able to set the Format property of your DateTimePicker control to "Short." That will chop off the Time value.

Then, in your query statement, instead of matching the Date field as is, use Format([DateField], "mm/dd/yyyy") in your WHERE clause.
 
You could use ...

dteMydate = datevalue(datetimepicker1.value) if you want just the date or ...

dteMytime = timevalue(datetimepicker1.value) if you want just the time.

 
I read your post again. You could try something like this maybe?

SELECT * FROM [Table_name] WHERE [Entry_date] >= datevalue(datetimepicker1.value) & " 00:00:00" AND [Entry_date] <= datevalue(datetimepicker1.value) & " 24:00:00"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top