Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Formula Field to concatenate Text and Date Post Reply Post New Topic
Author Message
nkdata
Newbie
Newbie


Joined: 30 Sep 2014
Online Status: Offline
Posts: 6
Quote nkdata Replybullet Topic: Formula Field to concatenate Text and Date
     Posted: 02 Oct 2014 at 8:31am
I'm a newbie, it doesn't seem like it should be too hard, but I keep getting an error.
I need help to create a formula field in Crystal Reports 2008. I need the field to take the current year, if the "from date of service" is greater than or equal to 01/01/current year, it should enter the quarter of the service year (ex: 3 Qtr 2014). If the "from date of service" is less than the current year, it should enter CY + year of service (ex: CY 2012).

In excel it looks like this
IF(D1>=1/1/2014,INT(INT(MONTH(D1)+2)/3)&"-"&"QTR"&" "&TEXT(D1,"YYYY"),"CY"&"-"&TEXT(D1,"YYYY"))
where D1 is the cell containing the "from date of service"

Can you help???
new to this I NEED HELP
IP IP Logged
nkdata
Newbie
Newbie


Joined: 30 Sep 2014
Online Status: Offline
Posts: 6
Quote nkdata Replybullet Posted: 02 Oct 2014 at 10:07am
ok, I can get the calculation to happen but still can't add text. How can I modify this

if Year({Command.FROMDATESVC}) = Year (CurrentDate) then INT(INT(MONTH({Command.FROMDATESVC})+2)/3) else Year ({Command.FROMDATESVC})

to add the "Qtr" or "CY" text??
new to this I NEED HELP
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 02 Oct 2014 at 3:33pm
if Year({Command.FROMDATESVC}) = Year (CurrentDate) then
totext(datepart("q",{Command.FROMDATESVC}),0)&"qtr" else totext({Command.FROMDATESVC},"yyyy")&"CY"
IP IP Logged
nkdata
Newbie
Newbie


Joined: 30 Sep 2014
Online Status: Offline
Posts: 6
Quote nkdata Replybullet Posted: 20 Oct 2014 at 8:33am
That worked. Thanks DBlank
new to this I NEED HELP
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