Joined: 27 Aug 2015
Online Status: Offline
Posts: 1
Topic: How to compare months of two dates? Posted: 21 Sep 2015 at 6:53pm
I have seven dates on my crystal report.I need to compare month of each date with the date the report is made to run(@Datebeg is the field for report date). I am using formula on my report as:
if month({Date1})=month(cdate({@Datebeg})) and
month({Date2})=month(cdate({@Datebeg})) and
month({Date3})=month(cdate({@Datebeg})) and
month({Date4})=month(cdate({@Datebeg})) and
month({Date5})=month(cdate({@Datebeg})) and
month({Date6})=month(cdate({@Datebeg})) and
month({Date7})=month(cdate({@Datebeg}))
then (H1+H2+H3+H4+H5+H6+H7) else 1.
Its giving me 1 each time.The comparison is failing.
As per my understanding, You want to compare all the dates with {@Datebeg} formula and if all the dates are matching with {@Datebeg} then you want to add something.
In above formula for all Date1, Date2... Date7 values should be same then only we can get addition values. if one of the Date filed values are not matched with {@Datebeg} formula then we will get result 1.
You can change your formula as below..
1)
if month({Date1})=month(cdate({@Datebeg})) or
month({Date2})=month(cdate({@Datebeg})) or
month({Date3})=month(cdate({@Datebeg})) or......
2)
if month({Date1})=month(cdate({@Datebeg}))
then (H1) else 1
if month({Date2})=month(cdate({@Datebeg}))
then H2 else 1
3)
{@Datebeg} in [{Date1},{Date2}.....{Date7}] then (H1+H2+H3+H4+H5+H6+H7) else 1.
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