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

SQL Statements and dates

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi

I need to execute some SQL statements that compare dates. Firstly I need to return all records that are 2 months older than a date stored as one of the fields.

Secondly need to return all reocrds that are older than the same date field stored as one of the fields.

Where can I find out information on using dates with SQL statements???

TIA
Paul.
 
Within the WHERE field you would use something like the following code:

Code:
SELECT tblA.* FROM tblA
 WHERE tblA.DateField > (SELECT DateAdd("mm",tblB.dateField, -2) As DateCheck FROM tblB WHERE id = 2)

A good place to look is SQL Server Books Online. If you do not have these installed then look at the following:


James :) James Culshaw
jculshaw@active-data-solutions.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top