views:

34

answers:

1

Hi,

I am trying to bring back records from a table called CTN_LIST where the created date is no older than 90 days. The code is below (created_dt<=-90)

Set PlatinumList = db.OpenRecordset("SELECT FORMATTED_CTN FROM CTN_LIST 
WHERE ((Status='Available') AND (Category='Platinum')) AND (In_Offer_List = True) 
AND (Created_DT<=-90);", dbOpenSnapshot, dbReadOnly)

Can someone please tell me the correct date format to ensure that I only bring back records that are less than 90 days old?

Thanks

+3  A: 

Try using Created_DT <= DATEADD(d, -90, Created_DT) in your query.

Ardman
In Access, you do need a function to subtract days and Date() is today's date: Created_DT >= Date()-90
Remou
...and the reason you don't is because dates are stored as a double, with the integer part being the number of days since 12/30/1899, and the decimal part being the fraction of a day.
David-W-Fenton