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

calculate 6 months of data for filter 1

Status
Not open for further replies.

giggles7840

IS-IT--Management
Mar 8, 2002
219
US
xir2/win xp

I need to bring in only 6 months of data based on a date field using the record selection editor.

there isnt a set function like lastfullweek, monthtodate, etc.

whats the best way to calculate this?
 
Hi,
look into using the dateDiff function:
Here is an example from the CR Help:
Code:
Use DateDiff with the "m" parameter to find the number of months difference between two dates.

DateDiff ("m", #3/15/1999#, #7/13/1999#)

Returns 4.
So, use it to set a record selection formula that
uses the date field in your data, something like:
Code:
DateDiff("m",{DateFieldInData},CurrentDate) = 6

[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Hi,
Actually the formula I posted would only get you data from exactly 6 months ago...modify it to get 6 month's worth of data:
Code:
DateDiff("m",{DateFieldInData},CurrentDate) <= 6



[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
The only issue I see with the above example is that it will NOT pass through to the SQL which will make your report less efficient.

Write the logic this way so that you can accomplish the SQL pass thru:

{table.datefield} >= DateAdd("m", -6, CurrentDate)

~Brian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top