Solved

Crystal Reports: determine date range in various weeks

Posted on 2014-07-22
2
483 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

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