Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: formula for month and year selection Post Reply Post New Topic
Author Message
gemcka
Newbie
Newbie


Joined: 02 Aug 2011
Online Status: Offline
Posts: 16
Quote gemcka Replybullet Topic: formula for month and year selection
     Posted: 14 Dec 2011 at 1:16am
Hi Guys,
 
I have this formula
 
IF MONTH({INVENTORY_TRANSACTION_HIST2.DATE_CREATED}) =  month(dateadd('m',-1,((currentdate))))
AND {INVENTORY_TRANSACTION_HIST2.TRANSACTION_CODE} in 'BACFLUSH''SOISS'
THEN {INVENTORY_TRANSACTION_HIST2.QUANTITY}
ELSE 0
 
which returns qtys for certain transaction codes for last month from the current date.
 
The problem is that it is also returning data from 13 months ago.
 
I have columns for current month and 1 - 6 months ago in the report
 
How do I set the year as well?
I can't just use the select expert to pick this year as when the report is run next month it will not return data for Jan 2012?
 
Many Thanks for any help
Gav
 
IP IP Logged
comatt1
Senior Member
Senior Member
Avatar

Joined: 19 May 2011
Online Status: Offline
Posts: 337
Quote comatt1 Replybullet Posted: 14 Dec 2011 at 3:01am

IF MONTH({INVENTORY_TRANSACTION_HIST2.DATE_CREATED}) =  month(dateadd('m',-1,((currentdate)))) and Year({INVENTORY_TRANSACTION_HIST2.DATE_CREATED}) =  year(dateadd('m',-1,((currentdate))))

then
IP IP Logged
gemcka
Newbie
Newbie


Joined: 02 Aug 2011
Online Status: Offline
Posts: 16
Quote gemcka Replybullet Posted: 14 Dec 2011 at 4:28am
perfect - Thank you
 
I really should start thinking more logically!!!!
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 14 Dec 2011 at 7:46am
you can also  use
IF {INVENTORY_TRANSACTION_HIST2.DATE_CREATED} in lastfullmonth then {INVENTORY_TRANSACTION_HIST2.QUANTITY}
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