Greetings!

I have database file with dateformat on a field.

I want to view the data on files according to its date range using vb6.

Like for example i want to view a file for starting date = 23/10/2007 upto 23/11/2007. Range of date is one month from starting date upto ending date.

I try the

syntax

my variable my field my 2nd variabled my field
...........|..................|....................|...........................|
if ((varstartdate >= fielddate) and (varenddate <= fielddate)) then
viewdata
endif

but it doesn't works.

Anybody have idea to view this file according to date range.

Thank you in advance

Try using the DateDiff function:

Dim TheDate As Date ' Declare variables.
Dim Msg
TheDate = InputBox("Enter a date")
Msg = "Days from today: " & DateDiff("d", Now, TheDate)
MsgBox Msg

Find out the dfference between both the dates using Datediff. then apply the logic U want to implement.

Write the following code
Pvt command1_click()
rs.open "Select * from <table name> where < field name> >= cdate('" & datepicker1.value & "') and <= cdate('" & datepicker2.value & "'),cn, adlockstatic, alockoptimistic,
endsub

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.