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

Print Date 1

Status
Not open for further replies.

SkyhiKeeper

Programmer
Jan 6, 2004
22
ZA
How do I set the print date dynamically I do not want to have to go into the set print date and time menu oprion , i want to prime the value from a parameter, How is this possible

Terence
 
Create a parameter in your report and then add this to your Record Selection Formula

{MyTable.DateField} = {?DateParam}

HTH

Gary Parker
MIS Data Analyst
Manchester, England
 
Hi Gary

It is actually not a filter that I want to use it for we, need to change the printdate so that the age functions (age0to30) work properly otherwise the aging functions change daily and we would like to run the aging on any day byt backdated.

Terence
 
This isn't possible from within cryatal the Print Date and Time can only be changed manually.

You could use a parameter to specify the date(s) you wish to use in your formula instead of using the age0to30days() function.

i.e. amend your formulas to

{MyTable.DateField} <= {?PmPrintDate} and {MyTable.DateField >= DateAdd('d',-30,{?PmPrintDate}

HTH

Gary Parker
MIS Data Analyst
Manchester, England
 
Dear Skyhikeeper,

Actually, there is an excellent example of how to do this in the sample reports that ship with Crystal. Look for the samples directory under reports, feature examples, Date Range Formula Report.

It uses the switch function and two parameters:

Reference Date and Reference Condition.

The report prompts you for a reference date which you can think of as your print date. All date calculations are done from that date!

Here is the selection criteria:

Code:
{Orders.Order Date} in
Switch
(
    {?reference condition} = "Aged 0 to 30 days",
        ({?reference date} - 30) To {?reference date},
    {?reference condition} = "Aged 31 to 60 days",
        ({?reference date} - 60) To ({?reference date} - 31),
    {?reference condition} = "Aged 61 to 90 days",
        ({?reference date} - 90) To ({?reference date} - 61),
    {?reference condition} = "All dates from today",
        Is >= {?reference date},
    {?reference condition} = "All dates from tomorrow",
        Is >= ({?reference date} + 1),
    {?reference condition} = "All dates to today",
        Is <= {?reference date},
    {?reference condition} = "All dates to yesterday",
        Is <= ({?reference date} - 1),
    {?reference condition} = "Calender 1st half",
        CDate(Year({?reference date}), 1, 1) To CDate(Year({?reference date}), 6, 30),
    {?reference condition} = "Calendar 2nd half",
        CDate(Year({?reference date}), 7, 1) To CDate(Year({?reference date}), 12, 31),
    {?reference condition} = "Calendar 1st quarter",
        CDate(Year({?reference date}), 1, 1) To CDate(Year({?reference date}), 3, 31),
    {?reference condition} = "Calendar 2nd quarter",
        CDate(Year({?reference date}), 4, 1) To CDate(Year({?reference date}), 6, 30),
    {?reference condition} = "Calendar 3rd quarter",
        CDate(Year({?reference date}), 7, 1) To CDate(Year({?reference date}), 9, 30),
    {?reference condition} = "Calendar 4th quarter",
        CDate(Year({?reference date}), 10, 1) To CDate(Year({?reference date}), 12, 31),
    {?reference condition} = "Last 4 weeks to Sunday",
        ({?reference date} - 27 - (WeekDay({?reference date}) - 1)) To
        ({?reference date} - (Weekday({?reference date}) - 1)),
    {?reference condition} = "Last 7 days",
        ({?reference date} - 6) To {?reference date},
    {?reference condition} = "Last full month",
        DateSerial(Year({?reference date}), Month({?reference date}) - 1, 1) To
        DateSerial(Year({?reference date}), Month({?reference date}), 1 - 1),
    {?reference condition} = "Last full week",
        ({?reference date} - 6 - WeekDay({?reference date})) To
        ({?reference date} - WeekDay({?reference date})),
    {?reference condition} = "Last year Month to Date",
        CDate(Year({?reference date}) - 1, Month({?reference date}), 1) To
        CDate(DateAdd("yyyy", -1, {?reference date})),
    {?reference condition} = "Last year Year to Date",
        CDate(Year({?reference date}) - 1, 1, 1) To
        CDate(DateAdd("yyyy", -1, {?reference date})),
    {?reference condition} = "Month to Date",
        CDate(Year({?reference date}), Month({?reference date}), 1) To {?reference date},
    {?reference condition} = "Next 30 days",
        {?reference date} To ({?reference date} + 30),
    {?reference condition} = "Next 31 to 60 days",
        ({?reference date} + 31) To ({?reference date} + 60),
    {?reference condition} = "Next 61 to 90 days",
        ({?reference date} + 61) To ({?reference date} + 90),
    {?reference condition} = "Next 91 to 365 days",
        ({?reference date} + 91) To ({?reference date} + 365),
    {?reference condition} = "Over 90 days",
        Is <= ({?reference date} - 91),
    {?reference condition} = "Week to Date from Sunday",
        ({?reference date}- (Weekday({?reference date}) - 1)) To {?reference date},
    {?reference condition} = "Year to Date",
        CDate(Year({?reference date}), 1, 1) To {?reference date},
    True, // provide default handling and specify a valid range
        CDate(1899, 12, 30) To CDate(1899, 12, 30)

Now, you can pull up this report, select the Reference Conditon parameter on the report and copy it to your report (you must actually select the parameter field on the report to copy) then paste. Now you have all the reference conditions ... delete any that do not apply and your users will not see them. Copy the reference date parameter to your report and finally copy the selection criteria to your report. The true beauty of the above select criteria is you only have to change the Orders.Ship Date to your date field. Just that one change and it passes to SQL!

I use this report in my Crystal Classes to show off the Switch function and it works really nice.

Enjoy,

ro

Rosemary Lieberman
rosemary@microflo.com, Microflo provides expert consulting on MagicTSD and Crystal Reports.
 
Thanks

It is such a pity that they have creaded the functions and a simple change of allowing the printdate to be changed ,you have to now build what these functions literally do.

Thanks once again

SkyhiKeeper
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top