Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: multiple date paramters - hard coding Post Reply Post New Topic
Author Message
spl1
Newbie
Newbie
Avatar

Joined: 18 Jun 2009
Location: United Kingdom
Online Status: Offline
Posts: 20
Quote spl1 Replybullet Topic: multiple date paramters - hard coding
     Posted: 06 Apr 2011 at 12:38am
Hi
I have created a report with two subreports. All 3 reports are date dependant and currently I ask the user to enter three start and finish dates. I am trying to hard code these dates but not the year, as I want basically the following rules :-
 
1. Start date = 1st Jan its end date = today
2. Start date = today plus 1 its end date is 31st Dec
3. Start date = 1st Jan its end date is 31st Dec
 
The reports are linked on other fields and not date.
 
But the key for me is that if they enter last years date - then all 3 start and end will be the same 1st Jan - 31st Dec
If they enter next years date then
1. start date = 1st Jan and its end date = 1st jan
2. start date = 2nd Jan and end date is 31st dec
3. start date 1st jan - end is 31st dec
 
I understand this isnt a one answer question but any help in trying to get there will be much appreciated... I'm trying to make it user friendly and so they only enter the year they want
Thank you in advance....
Sarah
IP IP Logged
Keikoku
Senior Member
Senior Member


Joined: 01 Dec 2010
Online Status: Offline
Posts: 386
Quote Keikoku Replybullet Posted: 06 Apr 2011 at 3:07am
How about prompting them to enter a year (string or number) and then constructing the dates manually?

ie: for me I'm using pl/sql so I would prompt them to enter a string and then I would just say


WHERE date >= to_date('{?date}/01/01', 'yyyy/mm/dd') ...


If it were not a query a selection formula should be fine as well.

If the user will be viewing the reports for the same year for all subreports, then having this single prompt should be fine I suppose? (I've never used subreports so I'm not sure if parameters are passed into them)

Edited by Keikoku - 06 Apr 2011 at 3:27am
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 06 Apr 2011 at 3:28am
Like Keikoku says, have them enter a year.  Link on the year parameter to pass it into your subreports - the trick here is to set the link, but don't select records based on the parameter.  You'll then create two formulas for the main report and each subreport.  Assuming that the parameter is called {?Year}, here's what your first two formulas will look like:
 
Date({?Year}, 1, 1)
 
If {?Year} < Year(CurrentDate) then Date({?Year}, 12, 31)
else if {?Year} > Year(CurrentDate) then Date({?Year}, 1, 1)
else CurrentDate
 
You should be able to figure out the other two sets based on these.
 
To use these, go to the Select Expert, click on the Show Formula button and edit the formula so that you have access to add the formulas you just created to your filter.
 
-Dell
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum