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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selecting Current Week/Shift Block

Status
Not open for further replies.

BobHunter

Programmer
Mar 26, 2001
62
0
0
GB
Here's a teaser, not unlike my last post where I asked how to select the previous 12 hour period.

I now need to select the current week for a report, where the StartDate will default to Saturday, 7am current week, and the EndDate will default to Saturday 7am next week.

Eg. Today is 21st Jan
StartDate should be 17th Jan 7am
EndDate should be 24th Jan 7am

Any takers ?

TIA - Bob.

 
Bob:

Place this in you Record Selection Criteria:
Code:
{table.datefield} IN DateAdd("h",-17,Minimum(WeekToDateFromSun)) to DateAdd("h",7,Maximum(WeekToDateFromSun))
This will get converted and passed with your SQL

~Brian
 
I just realized that it will only go to 7am on the day after the current date. I will continue to try and ge the whole week.

~Brian
 
This should do it for you:
Code:
{Orders.Order Date} IN DateAdd("h",151,Minimum(LastFullWeek)) to DateAdd("h",175,Maximum(LastFullWeek))

~Brian
 
Here's another that should passes as well:

{Table.DateField} >= datetime(date(dateadd("d", - DayOfWeek ({?Date}, crSaturday) + 1, {?Date})), time(07, 00, 00))
and
{Table.DateField} <= datetime(date(dateadd(&quot;d&quot;, 7 - DayOfWeek ({?Date} - 1, crsaturday) , {?Date})), time(07, 00, 00))

-dave
 
Both of these resulted in an application error - the dreaded red X - dunno why.

My date field in the db is formateed 21/01/04 12:10:00 if that helps.

Would formulae be better, passed in as 2 parameters ?

StartDate = CurrentDateTime etc ?

Thanks for the help thus far...

Bob.
 
What data type is you date format? Date type or character?

~Brian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top