Solved

Crystal Reports: determine date range in various weeks

Posted on 2014-07-22
2
526 Views
Last Modified: 2014-07-22
Hello Experts,

I have a chart that list data points for each week.  The table that I am using only has a field called "reporting_year_week", which displays weeks like "2014-W27".  I need help writing a formula that will evaluate the "2014-W27" and provide the following dates range.  Here are examples:
06/09-06/15
06/16-06/22
06/23-06/29
06/30-07/06

Unfortunately, if I had a single date in the table then I would be able to use a formula like this, but I don't so I have to evaluate the "2014-W27".

local datetimevar start;
local datetimevar end;
start:= CurrentDate-weekday(CurrentDate,2)+1;
End:=start+6;
{@reporting_year_week} & chr(10)&
totext(start,"MM/dd") & "-" &  totext(end, "MM/dd")
0
Comment
Question by:Maliki Hassani
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 101

Accepted Solution

by:
mlmcc earned 500 total points
ID: 40211864
Try this for the first day of the week

Local NumberVar myWeeks;

myWeeks := Val(Split({YourDateField},"W")[2]);

Date(DateAdd('ww',myWeeks,Date(2014,1,1)) - DayOfWeek (DateAdd('ww',myWeeks,Date(2014,1,1))) + 1)

Open in new window


Try this for the last day of the week
Local NumberVar myWeeks;

myWeeks := Val(Split({YourDateField},"W")[2]);

Date(DateAdd('ww',myWeeks,Date(2014,1,1)) - DayOfWeek (DateAdd('ww',myWeeks,Date(2014,1,1))) + 1) + 6

Open in new window


mlmcc
0
 

Author Comment

by:Maliki Hassani
ID: 40211885
That works!  Thanks mlmcc!
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

726 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