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

Future Month

Status
Not open for further replies.

lisa626

Programmer
Joined
Aug 9, 2006
Messages
92
Location
US
I have a report that I need to schedule to run based on what is GOING to happen per specific dates in report.

How can I tell it to pull data for next full week or next full month???

 
DateAdd("ww", 1, currentdate) and DateAdd("m", 1, currentdate)

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
I would use something like:

//{@nextfullwk}:
{table.date} in dateadd("ww",1,currentdate-dayofweek(currentdate)+1) to dateadd("ww",1,currentdate-dayofweek(currentdate)+7)

//{@nextfullmo}:
{table.date} in dateserial(year(currentdate),month(currentdate)+1,1) to dateserial(year(currentdate),month(currentdate)+2,1)-1

These are record selection formula. Not sure how you intended to use the formulas.

-LB
 
You can leverage built in functions as well:

//{@nextfullwk}:
{table.date} in minimum(lastfullweek)+7 to maximum(lastfullweek)+7

//{@nextfullmo}:
{table.date} in dateadd("m",1,minimum(lastfullmonth)) to dateadd("m",1,maximum(lastfullmonth))

-k
 
SV,

Note that dateadd("m",1,maximum(lastfullmonth) would result in October 30, not October 31. Also the OP wants the next month, not current month.

-LB
 
LB: Yeah, I wasn't sure what next full month meant, the next full month might mean the current month as by definition it is the next incomplete month.

Good point on the maximum function, that woiuldn't work correctly.

Anyway, to use your scenario:

//{@nextfullwk}:
{table.date} in minimum(lastfullweek)+14 to maximum(lastfullweek)+14

//{@nextfullmo}:
{table.date} in dateadd("m",2,minimum(lastfullmonth)) to dateadd("m",3,minimum(lastfullmonth))-1

The point was to just emphasize that built in date functions can be referenced as arrays. In CR 8.5 I would be hesitant to suggest this as it didn't do a good job of passing SQL, but later versions are much better.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top