Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Last 12 rolling months formula question... Please help 1

Status
Not open for further replies.

tctran

Technical User
Jun 5, 2014
8
0
0
US
Hello everyone,

I've created a report with a date selection parameter to allow users to select from a list of date range option from the Date Range function in Crystal Reports. However, the defaulted function doesn't have an option for last 12 months. I've attempted to create a formula for the Last 12 Months but keep getting an error stating "A boolean is required here". When I use the Last 12 Months formula by itself on a different report it work fine but when combining to the date range parameter below I get the error. Could someone please help me take a look at my Last 12 Months formula and let me know what I did wrong. I am using Crystal Reports 2008.

{Incdnt.FormCreateDate} in
(if {?Run Time Option} = 'Last Full Day' then (DataDate - 1) to (Datadate - 1) else
if {?Run Time Option} = 'Last Full Week' then LastFullWeek else
if {?Run Time Option} = 'Last Full Month' then LastFullMonth else
if {?Run Time Option} = 'Month To Date' then MonthToDate else
if {?Run Time Option} = 'Year To Date' then YearToDate else
if {?Run Time Option} = 'Last 12 Months' then {Incdnt.FormCreateDate} >= Date(DateAdd("m", -12, Date(Year(CurrentDate), Month(CurrentDate), 1))) and
{Incdnt.FormCreateDate} < Date(Year(CurrentDate), Month(CurrentDate), 1) else
{?Date Range})

Thank you so much for your assistance in advance!

TC
 
Hello TC,

Change the last if like this:
if {?Run Time Option} = 'Last 12 Months' then
Date(DateAdd("m", -12, Date(Year(CurrentDate), Month(CurrentDate), 1))) to Date(Year(CurrentDate), Month(CurrentDate), 1)
else
{?Date Range})

D

 
Hello D,

Thank you so much for the helpful tip!!! This works perfectly! I really appreciate you for spending time to help me with the formula! Thanks a bunch!

TC
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top