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

PRE-DEFINED DATE RANGE 1

Status
Not open for further replies.

reidtw

MIS
Feb 10, 2004
74
0
0
GB
Hi, had difficulty working this out, wonder if anyone can help...

I'm using cr8 to a sql w2k database.

I would like to hard code the date range so that the previous 18 months of data automatically renders based on a particular data field.

For instance, I refresh the report on any day in July 2006 and the previous 18 months data is chosen, i.e 1st of Jan 2005 to 30th Jun 2006; in the next month I run the report and the data for 1st feb 2005 to 31 Jul 2006 is rendered, and so on.

I was trying to use dateserial but it isn't worth showing you what I did!

Any help would be appreciated.
 
You should be able to use:

{table.date} in dateserial(year(currentdate-day(currentdate)),month(currentdate-day(currentdate))-17,1) to
dateserial(year(currentdate-day(currentdate)),month(currentdate-day(currentdate))+1,1)-1

-LB

 
lbass,

Perfect!

Is there any documentation you know of that actually explains generically what each part of the formula is doing, as the cr help is vague, so I can understand it!

Thanks
T
 
Currentdate-day(currentdate) returns the last day of the previous month. In the second half of the formula, adding one month returns the first day of the next month, and then subtracting 1 from that returns the last day of the previous month.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top