Solved

Crystal Syntax for finding Last Week's (Mon-Sun) data

Posted on 2009-05-06
6
692 Views
Last Modified: 2013-11-15
Hi,

I'm trying to figure out the Crystal Syntax to bring back all data for last week (Mon - Sun) no matter what the current day is, and without using parameter fields.

Thank you in advance,

Parachute  

// This is the code I currently use with date parameters, but I want to do away the paramter field

// so I can schedule the report to run any day of the week and still bring back data from last 

// Mon-Sun
 

(({Ticket.OpenDate} in datetime({?BeginDate}) to datetime({?EndDate})+1)

or 

({@ResolveDate} in datetime({?BeginDate}) to datetime({?EndDate})+1)

or

({@ResolveDate} > datetime({?Begindate}) and {Ticket.OpenDate} < datetime({?EndDate})+1))

Open in new window

0
Comment
Question by:parachute_505
  • 3
  • 3
6 Comments
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
Crystal has a LastFullWeek range function.  Unfortunately it returns Sun thru Sat

Try it this way

{Ticket.OpenDate}-1 in LastFullWeek

If you need the other date checks
(({Ticket.OpenDate} - 1 in LastFullWeek)
or
({@ResolveDate} in LastFullWeek)
or
({@ResolveDate} > Minimum(LastFullWeek) and {Ticket.OpenDate} < Maximum(LastFullWeek)+1))

mlmcc
 
0
 

Author Comment

by:parachute_505
Comment Utility
mlmcc,

Thank you for the quick response.  I am new to using Crystal Syntax, could you explain the need to have "Maximum(LastFullWeek)+1)?  Why does the "+1" need to be there if maximum(LastFullWeek) alread refers to Sunday?

Thanks again

Parachute
0
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
Maximum(LastFullWeek) is last Saturday.  SInce you want through sunday you have to add 1 day (actually 2 to get to Monday).

mlmcc
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:parachute_505
Comment Utility
Perhaps I'm misunderstanding the LastFullWeek function.  My understanding is that the LasFullWeek() is Sunday-Saturday.  So I thought maybe if I wrote --> {Ticket.OpenDate} in dateadd("d",1,minimum(LastFullWeek)) to dateadd("d",1,maximum(LastFullWeek)) that I would get Monday-Sunday

====================================================
This is what I came up with, but it is returning Monday-Saturday
====================================================
(({Ticket.OpenDate} in dateadd("d",1,minimum(LastFullWeek)) to dateadd("d",1,maximum(LastFullWeek)))
or
({@ResolveDate} in dateadd("d",1,minimum(LastFullWeek)) to dateadd("d",1,maximum(LastFullWeek)))
or
({@ResolveDate} > dateadd("d",1,minimum(LastFullWeek)) and {Ticket.OpenDate} < dateadd("d",1,maximum(LastFullWeek))))

====================================================
I need Monday-Sunday so I added "+1"
====================================================
(({Ticket.OpenDate} in dateadd("d",1,minimum(LastFullWeek)) to dateadd("d",1,maximum(LastFullWeek)+1))
or
({@ResolveDate} in dateadd("d",1,minimum(LastFullWeek)) to dateadd("d",1,maximum(LastFullWeek)+1))
or
({@ResolveDate} > dateadd("d",1,minimum(LastFullWeek)) and {Ticket.OpenDate} < dateadd("d",1,maximum(LastFullWeek)+1)))
0
 
LVL 100

Accepted Solution

by:
mlmcc earned 500 total points
Comment Utility
The problem is probably you have a DATE-Time field and the time on the LastFullWeek will be 00:00

You could use
dateadd("d",2,maximum(LastFullWeek)



(Date(({Ticket.OpenDate}) in dateadd("d",1,minimum(LastFullWeek)) to dateadd("d",1,maximum(LastFullWeek)))
or
(Date({@ResolveDate}) in dateadd("d",1,minimum(LastFullWeek)) to dateadd("d",1,maximum(LastFullWeek)))
or
(Date({@ResolveDate}) > dateadd("d",1,minimum(LastFullWeek)) and {Ticket.OpenDate} < dateadd("d",1,maximum(LastFullWeek))))


mlmcc
0
 

Author Comment

by:parachute_505
Comment Utility
mlmcc,

Thanks again for your help.  I was able to use the syntac below and have it work 99.9% successfully.  The other 0.1% I used your suggestion on a field that uses the SUM function --- CDate(dateadd("d",2,maximum(LastFullWeek))) --- or ---  CDate(dateadd("d",1,maximum(LastFullWeek)+1))

// Syntax to return data for Previous Week (Mon-Sun) without using data parameter fields
(({Ticket.OpenDate} in CDate(dateadd("d",1,minimum(LastFullWeek))) to CDate(dateadd("d",1,maximum(LastFullWeek))))
or
({@ResolveDate} in CDate(dateadd("d",1,minimum(LastFullWeek))) to CDate(dateadd("d",1,maximum(LastFullWeek))))
or
({@ResolveDate} > CDate(dateadd("d",1,minimum(LastFullWeek))) and {Ticket.OpenDate} < CDate(dateadd("d",1,maximum(LastFullWeek)))))
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
I recently went through setting up a JasperReports Server using the AWS EC2 instance, and this article will cover some basic administration tasks I had to perform.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now