Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculate only the last 3 FULL Weeks using crystal reports formula 1

Status
Not open for further replies.

angel7170

Programmer
Mar 12, 2009
15
US
Hello,

How can I filter a report to just show only the last 3 FULL WEEK (not the current week)( SUNDAY - SATURDAY) records?

I am using the formula

datefield >= dateadd("WW", -3, today) but this includes the data from the current week too because I have startdate = today
How can I change the startdate = start from last Saturday.
Please assist. Thank you so much
 
Try

Datefield <= dateadd("d",-(dayofweek(datefield)+1), datefield) and
Datefield >= dateadd("d",-(dayofweek(datefield)+22), datefield)

Ian
 
Thank you so much for replying

I tried this formula it doesn't return anything. please assist.
Thank you
 
Place each part in a separate formula and see if correct dates are returned

Ian
 
Code:
{MyTable.DateField} >= Today - (DayOfWeek (Today,crSunday) - 1) - 22 and
{MyTable.DateField} <= Today - (DayOfWeek (Today,crSunday) - 1)

Gary Parker
MIS Data Analyst
Manchester, England
 
OOPS

Well spotted Gary

Mine should have been

Datefield <= dateadd("d",-(dayofweek(currentdate)+1), currentdate) and
Datefield >= dateadd("d",-(dayofweek(currentdate)+22), currentdate)

Doh!
 
Thank you both Gary and Ian!

I used the formula as you said,

{HPD_Help_Desk.Reported_Date} >= Today - (DayOfWeek (Today,crSunday) - 1) - 22 and
{HPD_Help_Desk.Reported_Date} <= Today - (DayOfWeek (Today,crSunday) - 1)

As of today , 3/18/2009
(Thursday) the output I got is starting from 2/21/2009(Saturday) to 3/15/2009 (Sunday)

But I want the data starting from 2/22/2009 (Sunday) to 3/14/2009(Saturday).
please assist!

Thank you



 
I tried the below formula

{HPD_Help_Desk.Reported_Date} > Today - (DayOfWeek (Today,crSunday) - 1) - 22 and
{HPD_Help_Desk.Reported_Date} < Today - (DayOfWeek (Today,crSunday) - 1)

It works now. Thank you again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top