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
Solved

Crystal Reports: determine date range in various weeks

Posted on 2014-07-22
2
494 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
2 Comments
 
LVL 100

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

The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

Question has a verified solution.

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

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 …
If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

809 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