Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Report Design
Message Icon Topic: Current date as default in Date Parameter ?? Post Reply Post New Topic
Author Message
jbalbo
Senior Member
Senior Member
Avatar

Joined: 17 Feb 2011
Online Status: Offline
Posts: 219
Quote jbalbo Replybullet Topic: Current date as default in Date Parameter ??
    Posted: 14 Jun 2013 at 9:43am
Does anyone know how to do current date as a default parameter?

I tried :

this formula
DateVar StartDate;
If {?Thru Date} = Date('1/1/1900') then
(
  StartDate := DateAdd('m', -1, CurrentDate);
  StartDate := Date(Year(StartDate), Month(StartDate), 1);
)
else
  StartDate := {?Thru Date};
StartDate


but getting a date is required error on the DateAdd ??

Any ideas would be great

Thanks
Joe


IP IP Logged
praveeng
Senior Member
Senior Member
Avatar

Joined: 11 Jul 2011
Online Status: Offline
Posts: 165
Quote praveeng Replybullet Posted: 17 Jun 2013 at 4:31am
Hi,
 
DateAdd function returns DateTime value, but in your case you have defined StartDate as Date field.
Change the formula as below in 4 th line,
 
StartDate := Date(DateAdd('m', -1, CurrentDate));
 
P.S: Do you want to assign current date or First day of the current month, because using your formula it will assign first day of the current month.
Praveen Guntuka,
praveen_guntuka@yahoo.com
IP IP Logged
jbalbo
Senior Member
Senior Member
Avatar

Joined: 17 Feb 2011
Online Status: Offline
Posts: 219
Quote jbalbo Replybullet Posted: 17 Jun 2013 at 5:26am
Thanks

That formula works now..
But unlike SSRS why can't I put today's date in the default value in the parameter?

I use 1/1/1900 in the default which gives me today's data, but if someone what's to use yesterday, they have to manipulate the calender from 1900...


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.