Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Changing Date parameter to 1st of month to "Today" Post Reply Post New Topic
Author Message
Jon K
Newbie
Newbie
Avatar

Joined: 12 Aug 2009
Location: United States
Online Status: Offline
Posts: 8
Quote Jon K Replybullet Topic: Changing Date parameter to 1st of month to "Today"
     Posted: 25 Jun 2013 at 2:28am
Hi All,

I need to change a report from accepting a parameter/input of a date range to defaulting to "From the first of this month to today".

Currently it has this in the selection formula:

{CUSTOMER_ORDER.ORDER_DATE} = {?Order Date Range}

So if the report were run today, 6/25, I would need 6/1 - 6/25 automatically without prompt/parameter.  Is this doable?  Not a very good Crystal formula guy yet!

Thank for your help everyone

Jon


Edited by Jon K - 25 Jun 2013 at 2:35am
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 25 Jun 2013 at 10:42am
in the record selection formula:
local datetimevar fom := CDATE(year(today), month(today), 1);
if {table.dateField} in fom to today then
true
else
false

my syntax for the cdate() function may be off, just going be memory. Regardless, this would be the correct idea

HTH
IP IP Logged
Jon K
Newbie
Newbie
Avatar

Joined: 12 Aug 2009
Location: United States
Online Status: Offline
Posts: 8
Quote Jon K Replybullet Posted: 25 Jun 2013 at 5:05pm
Thanks Lockwelle - I will try this tomorrow!
IP IP Logged
Jon K
Newbie
Newbie
Avatar

Joined: 12 Aug 2009
Location: United States
Online Status: Offline
Posts: 8
Quote Jon K Replybullet Posted: 26 Jun 2013 at 1:48am
Lockwelle - here is my whole record selection:

{@Prime} and
not({@Consignment}) and
{@OrderSelect} and
{@StatusSel} and
local datetimevar fom := CDATE(year(today), month(today), 1);
if {CUSTOMER_ORDER.ORDER_DATE} in fom to today then
true
else
false
//{CUSTOMER_ORDER.ORDER_DATE} = {?Order Date Range} and
//{@StatusSel}

When I save and close I get an error on the line I highlighted saying "A boolean is required here."

Any thoughts?
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 26 Jun 2013 at 4:34am
I would try something like this:

local datetimevar fom := CDATE(year(today), month(today), 1);

{@Prime} and
not({@Consignment}) and
{@OrderSelect} and
{@StatusSel} and
{CUSTOMER_ORDER.ORDER_DATE} in fom to today
//{CUSTOMER_ORDER.ORDER_DATE} = {?Order Date Range} and
//{@StatusSel}

declare the variable, then you can use it in the statement as completely boolean expression and CR should be happier.

HTH
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