Wednesday, June 3, 2015

Crystal Reports : The LastWeek Function

This is a nice trick for those of you that want to cut down on parameter input for your end users.

Suppose a report needs to only print records with dates from last Monday through Friday. You could of course provide a date range parameter and let the user choose for each printing of the report.

You could however, use the nifty LastFullWeek function in crystal to return these values automatically.

The first thing to keep in mind here is that LastFullWeek will actually return a Date Range, NOT a Date Value. In order to see what dates LastFullWeek is actually returning, we will need to create two formula fields. {@DateStart} and {@DateEnd}.

The code for {@DateStart} : MINIMUM(LastFullWeek)
The code for {@DateEnd} : MAXIUMUM(LastFullWeek)

Drag those two fields onto your report. You'll see that in the Crystal Universe, the LastFullWeek starts on a SUNDAY and ends on a SATURDAY. So if we just want Monday through Friday, we need to do some tweaking.

The code for {@DateStart} : MINIMUM(LastFullWeek) + 1
The code for {@DateEnd} : MAXIUMUM(LastFullWeek) - 1

Now the formulas are returning Monday to Friday and we can use them in our Selection Criteria thusly (assuming we are looking at a field called {HISTORY.ONDATE})

{HISTORY.ONDATE} IN {@DateStart} TO {@DateEnd}.

Try it!


Chanel Bottle said...

Cyanogen allows you to tinker with the OS and even change how a particular app looks on the screen, apply different themes and control privacy permissions for each app, something that Android does not natively support.

PLC training in chennai said...

WIZTECH Automation, Anna Nagar, Chennai, has earned reputation offering the best automation training in Chennai in the field of industrial automation. Flexible timings, hands-on-experience, 100% practical. The candidates are given enhanced job oriented practical training in all major brands of PLCs (AB, Keyence, ABB, GE-FANUC, OMRON, DELTA, SIEMENS, MITSUBISHI, SCHNEIDER, and MESSUNG)

PLC training in chennai
Automation training in chennai
Best plc training in chennai
PLC SCADA training in chennai
Process automation training in chennai
Final year eee projects in chennai
VLSI training in chennai