214-564-5316
Wednesday, May 21, 2008

An example of a database query by date



Here we have a database named test.mdb in a folder named database with field names First_Name, Last_Name, and Date_Expired in a table named clients. In the Access database the Date_Expired field has a data type of Date/Time and the Default Value is Date()+30 this means that every time a new entry is made in the database this field will automatically be a date that is "that day's date plus thirty days" and in the format mm/dd/yyyy). The results we are asking for here are "all the first and last names whose expiration date is between today and thirty days from now".  The sql statement looks like this: "SELECT First_Name,Last_Name,Date_Expired FROM Clients Where Date_Expired Between Date() And Date()+30 ORDER BY Date_Expired ASC"


Here are the results:



Here is the code for the entire page: