Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Formula for prompt date Post Reply Post New Topic
Author Message
petronas
Newbie
Newbie


Joined: 10 Nov 2008
Online Status: Offline
Posts: 6
Quote petronas Replybullet Topic: Formula for prompt date
    Posted: 13 Nov 2008 at 8:23am

Hi, 
My report has a Startdate prompt which lets you select 'M' - last month or you can enter any  date as a parameter.
based on what is selected in the prompt I need to display the last month.
If the report is run today choosing 'M' it should show Oct date.
if you enter a value in the prompt like 9/10/2008 then it should show Aug date.
I have to write a formula to get it.

If {?StartDate} = 'M' then
MonthName(month(DateAdd ('M', -1,CurrentDate)),True) & "-" & cstr(DateAdd ('M', -1,CurrentDate),"yyyy")
else
 {?StartDate} ( here I don;t know how to manipulate  {?StartDate} to make it point to last point last month, in this case Aug 2008)

Any ideas?
 
Thanks,
Petronas


Edited by petronas - 13 Nov 2008 at 1:40pm
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 13 Nov 2008 at 5:08pm
Just use the first formula, but substitute CurrentDate with {?StartDate}. Since they are both dates, the formulas will work the same.
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
petronas
Newbie
Newbie


Joined: 10 Nov 2008
Online Status: Offline
Posts: 6
Quote petronas Replybullet Posted: 13 Nov 2008 at 6:17pm
Hi Brian,
 
Thanks for your response. Actually I  have tried doing it but it is throwing an error "String required". As, {?startdate} is a string.
By the way, I just bought your book from Amazon, can't wait to get it.
 
Thanks for your help,
Petronas
IP IP Logged
petronas
Newbie
Newbie


Joined: 10 Nov 2008
Online Status: Offline
Posts: 6
Quote petronas Replybullet Posted: 13 Nov 2008 at 6:32pm
Hi Brian,
 
I got it. Just added cdate({startdate}) and it worked fine.
 
Thanks for your help,
Petronas
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.