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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selecting Recrods that fall between two dates 1

Status
Not open for further replies.

jamesmooredabest

Programmer
Mar 2, 2004
3
GB
I am new to programming, and I would like to know if it is possible to select records from customers that haven't been for a tyre change for over a year.

This is some information that I have found, but it makes no sense to me.
Data1.RecordSource = "Select * From FlyingTime where PilotMN = '" & txtID.Text & "' And FlightDate >= #" & startDate & "# and FlightDate <= #" & endDate & "#;"
Data1.Refresh

The above statement retrieves the records that match the field txtID.text and fall between the shown two date variables.
Unquatoe

I only need to select records that are between to dates something like this

adojobs.RecordSource = "Select * From jobs where Date >= #" & startDate & "# and Date <= #" & endDate & "#;"

I have tried this and this doesn't work. I need to know how to set up the startDate and the endDate. They startdate date should be 365 days from NOW, and the enddate should be 395 days from NOW. I have no idea how to do this.

Thank you very much

James
 


Look up DateDiff() in Access Help. The SQL will go along these lines:

SELECT * from tbl where datediff("d", dtLastTireChange, now()) > 365



Mark

&quot;You guys pair up in groups of three, then line up in a circle.&quot;
- Bill Peterson, a Florida State football coach
 

Data1.RecordSource = "SELECT * FROM FlyingTime WHERE (PilotMN = '" & txtID.Text & "') AND (FlightDate BETWEEN #" & Format$(Date + 365,"yyyy-mm-dd") & "# AND #" & Format$(Date + 395,"yyyy-mm-dd") & "#)"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top