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

CR XI - Date Formula for Report Expert

Status
Not open for further replies.

CRXIuser2005

Programmer
Sep 23, 2005
135
US
How would I be able to have a report AUTOMATICALLY run a date range as follows:

I would like to tell my report to always print detail for the last 3 months. So, using today as an example (10/26/05), I would like for my report to automatically calculate that it would need to run for the months of 08/01/05-10/26/05.

10/26/05 being the CURRENTDATE.

Can you tell me what formula to use to accomplish this?



Thank you.

MV

"A man is only as happy, as he makes up his mind to be....
 
CURRENTDATE-90 would give you 3 months previous date.
 
To get 08/01/05-10/26/05 with a current date of 10/26/05, define a formula field called @DateFrom
Code:
 Date(Year(Currentdate), Month(Currentdate), 01)
In the select statement, check {yourdate} >= @DateFrom. If you had records ahead of the current date (which is rare but not unknown on some databases) then also say and {yourdate} <= Currentdate



[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
Not clear on this yet. When I add @DateFrom to my report, it returns 10/01/05.

Is this correct? I need a formula that will automatically calc 3 months prior to current date. For today I need 08/01/05-10/27/05 as my reporting dates.

THANKS

Thank you.

MV

"A man is only as happy, as he makes up his mind to be....
 
OOps..Nevermind...IC....IC....thanks

Thank you.

MV

"A man is only as happy, as he makes up his mind to be....
 
I'm confused why you would continue this discussion when the solution has already been provided in thread767-1142716. Is there something that isn't quite working for you?

-LB
 
I should have said CURRENTDATE-90 where I said Currentdate, sorry. Glad it's working for you now.

It's also possible to subtract calendar months, DateAdd("m", -2, currentdate)

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top