Print Page | Close Window

Current date as default in Date Parameter ??

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=19659
Printed Date: 28 Apr 2024 at 8:35am


Topic: Current date as default in Date Parameter ??
Posted By: jbalbo
Subject: Current date as default in Date Parameter ??
Date 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





Replies:
Posted By: praveeng
Date 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


Posted By: jbalbo
Date 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...





Print Page | Close Window