Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 571
  • Last Modified:

Crystal formula or Command Date Buckets

trying to setup are report using some date fields to create some date buckets

So I have a start date and a end date as fields.

I want to create a command or use formulas(prefer) to calculate the dates between those start and end dates.

bucket 1is   enddate - startdate = time duration1  x .025,  then add this to  startdate

bucket 2 is enddate - startdate = time duration2  x .063 , then add this to startdate

bucket 3 is  enddate - startdate = time duration3  x .0125 , then add this to startdate

All Dates are actual numbers and I end up converting them over to dates to view them


Anyone have suggestion on how to do this?
0
shockacon
Asked:
shockacon
  • 6
  • 6
  • 2
1 Solution
 
mlmccCommented:
I am not clear what you are trying to do.

You can use DateDiff to subtract dates with you choice of days, weeks, hours, etc
You can then use DatsAdd to add the units back

mlmcc
0
 
shockaconAuthor Commented:
OK so I did this and it works!! :)

Anyway i now believe i need to put it all into one formula, as Im trying to get this into a crosstab scenario..

this is what I want to do.. is it possible in one formula to have multiple "buckets" or results? Im getting a "Boolean is required" or" ) is missing"  etc. errors..


if ((ESPs_ARSToLocalDate ({@lts - ops}* .025) + {projectdesc.opsStart}))
then 'milestone1'

else if ((ESPs_ARSToLocalDate (({@lts - ops}* .088) + {projectdesc.opsStart})

then 'milestone2'
else  '0'
0
 
mlmccCommented:
The value of the test must be true or false

((ESPs_ARSToLocalDate ({@lts - ops}* .025) + {projectdesc.opsStart}))
This results in a number

The second if is missing some )

II am still not clear what you are trying to do.
Can you give an example with data as to what goes in which bucket?
Yes, you can use a formula like you are trying to produce.

mlmcc
0
Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

 
shockaconAuthor Commented:
im trying to create buckets of time for projects its the  differences between a start date and end date of each project..  
the dates are a unix time stamp or something and im trying to increment up from beginning.. .025 .088. .095 etc etc


I have 9 buckets that each have the increment and they work. My thought was to put it into one formula as the end result is to put it into a crosstab , otherwise it would be "stacked" 9 times over and I wouldnt get the result I need, so again, I wanted to put it in one formula so i could crosstab it out.

make sense?
0
 
mlmccCommented:
Something like

If enddate - startdate = time duration1  x .025 then
    "bucket 1"
else if enddate - startdate = time duration2  x .063  then
    "bucket 2"
else ETC

mlmcc
0
 
shockaconAuthor Commented:
yes thats what i did.. and where im stuck.. its telling me "a boolean is required" on bucket 2 portion
0
 
mlmccCommented:
Can you paste the formula

mlmcc
0
 
shockaconAuthor Commented:
if ESPs_ARSToLocalDate (({@lts - ops}* 1.002) + {projectdesc.opsStart})
then 'milestone1'



else if ESPs_ARSToLocalDate (({@lts - ops}* 1.003) + {projectdesc.opsStart})
then 'milestone2'
else  '0'
0
 
mlmccCommented:
You have to compare the calculated field to something.  Look at my formula.

mlmcc
0
 
shockaconAuthor Commented:
I did and dont see the difference??
0
 
mlmccCommented:
Yours

if ESPs_ARSToLocalDate (({@lts - ops}* 1.002) + {projectdesc.opsStart})
then 'milestone1'

Mine
If enddate - startdate = time duration1  x .025 then
    "bucket 1"

Mine has the = to compare enddate - startdate to the time duration
Yours simply adds 2 numbers but doesn't compare it to anything

mlmcc
0
 
James0628Commented:
 I'm guessing that ESPs_ARSToLocalDate converts the calculated value to a date, so what you're ending up with is something like:

if #12/01/2010#
then 'milestone1'
else if #12/02/2010#
then 'milestone2'
else  '0'


 You have to do some kind of test on those dates (compare them with another date or check the month or something).  Just saying "if date" makes no sense to CR.  That's what mlmcc was getting at.

 James
0
 
shockaconAuthor Commented:
hmm.. maybe this cant be done then. not sure what dates I would be comparing it too.. (itself maybe?)

the ultimate goal is to get them in a pivot table thats why I was working to put them in one formula.
0
 
James0628Commented:
Maybe you can't.

 Looking back at your original and follow-up posts, you've said that you're trying to use start date and end date fields to define "buckets" and that you're trying to create a cross-tab.  So, presumably you want to use the difference between the dates in some way to define the columns or rows in a cross-tab.  In general, you could do that, in various ways.

 However, it looks like you're trying to create multiple "buckets" for each record.  You can't do that.  CR can only include each record in one group.  Going back to your original post:

bucket 1is   enddate - startdate = time duration1  x .025,  then add this to  startdate

bucket 2 is enddate - startdate = time duration2  x .063 , then add this to startdate

bucket 3 is  enddate - startdate = time duration3  x .0125 , then add this to startdate


 You have nothing there that says "use the first formula for these records, the second formula for those records, etc.".  Those formulas would return 3 separate values for each record, like you're trying to include each record in all 3 "buckets", which you can't do.

 If you're not actually trying to include each record in multiple "buckets", can you try again to explain exactly what you're trying to do?

 FWIW, going back to mlmcc's suggestion, he was assuming that "time duration1", "time duration2" and "time duration3" were fields or formulas in your report, so, for example, (enddate - startdate = time duration1 x .025) would be testing to see if (enddate - startdate) was equal to (time duration1 x .025).  In that case, you could have one formula that produced different values depending on whether (enddate - startdate) was equal to (time duration1 x .025), or (time duration2  x .063), or (time duration3  x .0125).  You could use that formula for the columns or rows in a cross-tab.

 However, I'm assuming that "time durationX" was referring to the result of (enddate - startdate), so (enddate - startdate = time duration1 x .025) really meant ((enddate - startdate) x .025).  In that case, you've got different 3 different formulas producing different values for the same record.

 James
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 6
  • 6
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now