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

Need help with a date Querey 1

Status
Not open for further replies.

cstringer

MIS
Nov 9, 2003
32
US
Hello all,
I have a table called "Database". Each entry in this table has a "Date Opened" field and a "Date Closed" field. What I am attempting to accomplish is to run a querey against that table and find all records that are two days old or older as long as the "Date Closed" field is Null. I am sure this can be done with a simple querey, but since I am fairly new at this the answer eludes me.

Thanks,
Chuck
 
in the criteria for the [date closed] put "IS NULL"

on the criteria for the [date opened] put " > DATE() - 2"

As long as your field format is a short date this should work.

 
Thanks for the quick reply!
What if the Date Opened and Date Closed fields were created by a Calender control and stored in a text format? Should I go back and change it or is there another way?
 
jhall01,

Thanks for the input. Your querey for some reason did not work but you did get me on the right track. I created 4 test records 3 of them were older than 2 days and 1 was not. The criteria that worked was [date opened] &quot; <Date()-2&quot;

Thanks!
 
In the field name you might put some formating code to convert from text to Short Date.

IE ConDate: FORMAT([date opened],&quot;Short Date&quot;)

Which will format the data to a short date and then you can run the criteria. This is also good incase the data comes accross as 2 different formats...it will always convert it to a short date before it does the critera
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top