Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Report Design
Message Icon Topic: Date Parameters Post Reply Post New Topic
Author Message
Abhi
Newbie
Newbie


Joined: 23 Jul 2012
Online Status: Offline
Posts: 12
Quote Abhi Replybullet Topic: Date Parameters
    Posted: 31 Jul 2012 at 10:18am
Hi All-

My Report is a table based and the parameters used to run the report are start and end date.

The Start date has below values
Yesterday
First day of Previous week
First day of Previous month
First day of Previous quarter
First day of Previous 12 Months
First day of Previous 6 Months

End Date Has below values
Today
Last day of Previous week
Last day of Previous month
Last day of Previous quarter

The user runs by selecting any of the values from start date and end date based these values ranges the report should get the orders created.

Please advise

Thanks!
Abhi


IP IP Logged
Sastry
Moderator
Moderator
Avatar

Joined: 16 Jul 2012
Online Status: Offline
Posts: 537
Quote Sastry Replybullet Posted: 31 Jul 2012 at 12:44pm
Hi
 
Create to static string parameters and give the same values as default values.
 
Create a Formula with the following to get StartDate Value and compare it with your database field in record selection.
 
Note : I am giving only for Start Date, you will have to write for End date.
 
Datevar StDate;
If {?StartDate} = 'Yesterday' then StDate: = Currentdate -1 
else
If {?StartDate} = 'First Day of Previous Week' then
    StDate: = dateadd('ww',-1,currentdate)-(weekday(currentdate)-2)
else
If {?StartDate} = 'First Day of Previous Month' then
    StDate: = dateadd('m',-1,currentdate)-day(currentdate)+1
else
If {?StartDate} = 'First Day of Previous Quarter' then
    StDate: =( if Month(currentdate) in [1,2,3] then date(year(currentdate)-1,10,1)
else
if Month(currentdate) in [4,5,6] then date(year(currentdate),01,01)
else
if Month(currentdate) in [7,8,9] then date(year(currentdate),04,01)
else
if Month(currentdate) in [10,11,12] then date(year(currentdate),07,01)
)
else
if {?StartDate} = 'First Day of Previous 12 Months' then
StDate: = date(year(dateadd('y',-1,currentdate)),month(currentdate),01)
else
if {?StartDate} = 'First Day of Previous 6 Months' then 
StDate:=date(year(dateadd('m',-6,currentdate)),Month(dateadd('m',-6,currentdate)),01)
StDate;
 
 
Thanks,
Sastry
IP IP Logged
Abhi
Newbie
Newbie


Joined: 23 Jul 2012
Online Status: Offline
Posts: 12
Quote Abhi Replybullet Posted: 01 Aug 2012 at 5:05pm
Hi Sastry

Thank You for your prompt response..
but I get an error saying date is required at the line dateadd('ww',-1,currentdate)-(weekday(currentdate)-2).

thks
Abhi
IP IP Logged
Sastry
Moderator
Moderator
Avatar

Joined: 16 Jul 2012
Online Status: Offline
Posts: 537
Quote Sastry Replybullet Posted: 02 Aug 2012 at 1:30pm
Hi
Initialize the variable with datetimevar
 
i.e.
 
datetimevar Stdate;
Thanks,
Sastry
IP IP Logged
Abhi
Newbie
Newbie


Joined: 23 Jul 2012
Online Status: Offline
Posts: 12
Quote Abhi Replybullet Posted: 02 Aug 2012 at 5:20pm
Well ..I used the date conversion and it worked out for me..

Again.. Thanks very much for your help..
Thks
ABHI
IP IP Logged
Post Reply Post New Topic
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



This page was generated in 0.031 seconds.