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

query question

Status
Not open for further replies.

rkferri

Programmer
Jul 26, 2004
17
US
I'm trying to display information from my access database by only displaying fields that are in the database for 90 days. I have a creation date which is the field I'm doing the 90 day compare on. Is there a quick and easy way to do this?

Thanks in advance,
Kelly
 
I think you can do math with the date() function, like

WHERE MyDateField > date()-90

Phil Hegedusich
Senior Programmer/Analyst
IIMAK
-----------
I'll have the roast duck with the mango salsa.
 
hi,

alternatively in ACCESS you can use the now() for the same as has been shown above e.g.:

Code:
  SELECT col1, col2, col3
  FROM MyTable
  WHERE MyDate >= now()-90

or you can compute the date using coldfusion and then query using that date e.g.:

Code:
 <cfset MyDateVariable = DateAdd("d", -90. now()) />
 <cfquery name="MyQuery" datasource="MyDB">
  SELECT col1, col2, col3
  FROM MyTable
  WHERE MyDate >= #MyDateVariable#
 </cfquery>

We never fail, we just find that the path to succes is never quite what we thought...
 
I don't know about access, doing math on a date, assumes days or what?

mysql has date function like data add, that work very similar to coldfusions dateAdd. Anything that can be done with SQL probably should be.

the only time I use CFML to insert or update a date field is when they HAVE to be the same.

Kevin

Phase 1: Read the CFML Reference
Phase 2: ???
Phase 3: Profit!
 
Adding to or subtracting from now() assumes days.

So, if now() is Thursday, now()-3 is Monday.

Phil Hegedusich
Senior Programmer/Analyst
IIMAK
-----------
I'll have the roast duck with the mango salsa.
 
Kevin,

you just work out how many days you would like to go back. as far as i'm aware in ACCESS there is no function for doing months or years ... but then i could be wrong as I'm a MySQL / MS SQL user myself.

We never fail, we just find that the path to succes is never quite what we thought...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top