Link to home
Start Free TrialLog in
Avatar of anbuvec
anbuvec

asked on

regarding database filter

i have a database which captures date and time in the following format
08/26/2012 5:58:42 PM
i need to filter all the data created on 08/26/2012
i have a datepicker control in VB
i need to use the datepicker control to select the date which i will be using to filter the data.
how to do that coz if i am using the query "Select * from table where datefield =#" & datepicker1.value & "#"
nothing is returned as it will search for exact value of date picker that would be 08/26/2012  but the actual value of the table is 08/26/2012 5:58:42 PM. how to give the query for filtering this situation. please help
Avatar of itmarsolutions
itmarsolutions
Flag of India image

you have to give the time in your query

"Select * from table where datefield between '" & datepicker1.value.ToString("yyyy MMM DD") & " 00:00'" to '" & datepicker1.value.ToString("yyyy MMM DD") & " 23:59'"
Avatar of anbuvec
anbuvec

ASKER

.tostring is not an attribute or function and more over the database field type for date value is date/time field. i have tried the following and it gave me object required error
"Select tablefield from table where datefield between '" & DTPicker1.Value.ToString("MM DD yyyy") & " 00:00' to '" & DTPicker1.Value.ToString("MM DD yyyy") & " 23:59'".
ASKER CERTIFIED SOLUTION
Avatar of owenacampbell
owenacampbell
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
did you can take the date part from the datepicker ?
Avatar of anbuvec

ASKER

Thank you so much owenacampbell... i was using the like command but i have missed the syntax i was using # instead of ' as that was a date field that is why i wanted to use = instead of like... it is just a syntax... but very quick and thank you for ur response... :D