Problem with Finding Records on Dates
I am a new user in VISUAL BASIC.
I have a form which I placed 2 DTPicker for dates
The structure of my table is
startdate ( Date )
amount ( Number )
The name of DTPicker component is as a sdate and edate
Inside the form I used this code
dummy.Source = "select * from payments where startdate >= #" & sdate & "# and startdate <= #" & edate & "# order by startdate"
If dummy.BOF = True And dummy.EOF = True Then
MsgBox "Record Not Found"
List1.AddItem sdate & " to " & edate
While Not dummy.EOF
If I select the dates from dtpickers like sdate="02/01/2009" and edate="04/01/2009"
its give me the messge record not found instead of in the table there is a record.
If I select the dates from dtpickers like sdate="04/01/2009" and edate="04/01/2009"
its give me the again same messge record not found although there is a record in the table.Its should find the record but its give me the nothing
Please help me in this matter.
If your database only has the date in it, no time part, then you may need to
strip off the default time part of each date. But if your database does have
date and time parts you may need to strip off the default times and hard
code the min and max time parts.
FYI: Dates are stored as numbers where the whole part is the date and the
'just remove the time part
dummy.Source = "select * from payments where startdate >= #" & Fix(sdate) & "# and startdate <= #" & Fix(edate) & "# order by startdate"
'remove and then hard code the time parts
dummy.Source = "select * from payments where startdate >= #" & Fix(sdate) & " 00:00:00# and startdate <= #" & Fix(edate) & " 23:59:59# order by startdate"
decimal part it the time, so using the Fix() function truncates the decimal
part, the time, making it just a date.
Thanks for the reply. I tried to both queries with fix function but the result is same nothing to change.
I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
Please use [Code]your code goes in here[/Code] tags when posting code.
Before posting your question, did you look here
Got a question on Linux? Visit our Linux sister site.
Modifications Required For VB6 Apps To Work On Vista
By DesiMcK in forum Database
Last Post: 04-22-2008, 05:03 AM
By vikassheelgupta in forum Java
Last Post: 07-22-2005, 06:35 AM
By VB6noobz in forum Database
Last Post: 02-20-2005, 02:46 PM
By Mustafa in forum VB Classic
Last Post: 11-30-2001, 08:56 AM
By v.des in forum Database
Last Post: 06-06-2000, 12:21 PM
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL