Solved

Crystal Reports: determine date range in various weeks

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

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…
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

707 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

14 Experts available now in Live!

Get 1:1 Help Now