Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Help with Formula Post Reply Post New Topic
Author Message
colinh10
Newbie
Newbie
Avatar

Joined: 17 Jan 2012
Location: United Kingdom
Online Status: Offline
Posts: 5
Quote colinh10 Replybullet Topic: Help with Formula
     Posted: 19 Jan 2012 at 4:11am
Hi
 
Please can somebody help me with a formula (sorry new to crystal).
This is what I have tried and the idea is that I want to charge a different fee depending on session duration time:
 
If {'Cost_allocation_'.Session Duration} <> [00:05:00] then 2.50 else if {'Cost_allocation_'.Session Duration}> [00:05:00] then 5.00
 
I am using version 10 and the error is advising that a "the ] is missing"
 
Thanks
Colin
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 19 Jan 2012 at 4:17am
what data type is session duration...numeric? string? time? datetime?
 
IP IP Logged
rkrowland
Senior Member
Senior Member
Avatar

Joined: 20 Dec 2011
Location: England
Online Status: Offline
Posts: 259
Quote rkrowland Replybullet Posted: 19 Jan 2012 at 4:18am
Well first of all, you're aware that this formula is always going to return a value of 2.50 or null?
 
Any session duration not equal to 5 minutes will return 2.50, any that are equal to 5 minutes will return null as they're not greater than 5 minutes (your second if clause).
 
As for the error you're getting, try replacing the [ & ] with #.
 
If that doesn't work, I'd assume your Session Duration field isn't a datetime field and I'd need more information to help you (the datatype of the field).
 
Regards,
Ryan.


Edited by rkrowland - 19 Jan 2012 at 4:24am
IP IP Logged
colinh10
Newbie
Newbie
Avatar

Joined: 17 Jan 2012
Location: United Kingdom
Online Status: Offline
Posts: 5
Quote colinh10 Replybullet Posted: 19 Jan 2012 at 4:35am
DBANK the session duration is a custom style (dateTime)
RK Yes I noticed that I had a <> in the 1st part it should only read < , not sure I understand your remark about replacing [&] with #??
 
Thanks for your help.
 
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 19 Jan 2012 at 4:38am
If time({'Cost_allocation_'.Session Duration}) < time(0,5,0) then 2.50 else if time({'Cost_allocation_'.Session Duration})> time(0,5,0) then 5.00
 
//NOTE if it = 00:05:00 then you still have 0 as a result. you may want one of these to also use an =


Edited by DBlank - 19 Jan 2012 at 4:40am
IP IP Logged
colinh10
Newbie
Newbie
Avatar

Joined: 17 Jan 2012
Location: United Kingdom
Online Status: Offline
Posts: 5
Quote colinh10 Replybullet Posted: 19 Jan 2012 at 5:05am
That works thanks for your 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