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

Search by days to display last week date

Status
Not open for further replies.

trustsun

Technical User
Feb 4, 2004
73
0
0
US
I’m trying to use a date add function to pull last weeks data by day e.g. (Monday, etc.) in its current field. Here’s what I tried so far, =DateAdd("y",-7, [mydatefield]). Reiterating:
 

The code belows return the first day of the week:
Code:
Me.StartDate = Me.CalPick - Weekday(Me.CalPick, vbMonday) + 1

For info CalPick is a calender control, to get the date for the end of the week you could use:

Code:
Me.EndDate= Me.CalPick - Weekday(Me.CalPick, vbMonday) + 7

You should be able to adapt this to achieve the desired results.

HTH
 
I am not sure how to apply your example? I just want to put it in a SQL. This will also generate a make table query as well.
Reiterating: I would like to see the date from last week day: So if I have a query that run for Monday what will be last week date for Monday? Here's what I got so far:
DateSerial(Year([mydatefield]),Weekday([mydatefield])+7,-1)close but not close enough.

 
Trustsun

Sorry, had my 'form' head on, not sure exactly what you are asking for, if you want the date to be returned to always be the 'Monday' then use the following:

Expr1: [mydatefield]-Weekday([mydatefield])+2

If this is not waht you want then post your sql.

HTH


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top