Just the week please

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form that the client has requested has all the data from a week
(Calander Week). I know that I could use a between date lookup and hope that
the user gets the dates for the week right. But as I think about it, can I
set it up so that if the user puts in a date, any date the query would pull
all the records that fall on that calander week?

So for this week if the user puts in 11 Jan 05 the query would get all the
dates 10 - 16 Jan 05?

Any help would be great
 
I have a form that the client has requested has all the data from a week
(Calander Week). I know that I could use a between date lookup and hope that
the user gets the dates for the week right. But as I think about it, can I
set it up so that if the user puts in a date, any date the query would pull
all the records that fall on that calander week?

So for this week if the user puts in 11 Jan 05 the query would get all the
dates 10 - 16 Jan 05?

Any help would be great

Take your pick:

WHERE DatePart("ww",[ADate])=DatePart("ww",[Enter a date]) AND
Year([ADate])=Year([Enter a date])

or...

WHERE Format([ADate],"ww yyyy")=Format([Enter a date],"ww yyyy")
 
THANKS FRED!!!!!

fredg said:
I have a form that the client has requested has all the data from a week
(Calander Week). I know that I could use a between date lookup and hope that
the user gets the dates for the week right. But as I think about it, can I
set it up so that if the user puts in a date, any date the query would pull
all the records that fall on that calander week?

So for this week if the user puts in 11 Jan 05 the query would get all the
dates 10 - 16 Jan 05?

Any help would be great

Take your pick:

WHERE DatePart("ww",[ADate])=DatePart("ww",[Enter a date]) AND
Year([ADate])=Year([Enter a date])

or...

WHERE Format([ADate],"ww yyyy")=Format([Enter a date],"ww yyyy")
 
I cant input this code I keep getting a invalid syntext. It looks like it is
looking at the first format in the code.

WHERE Format([ADate],"ww yyyy")=Format([Enter a date],"ww yyyy")


KAnoe said:
THANKS FRED!!!!!

fredg said:
I have a form that the client has requested has all the data from a week
(Calander Week). I know that I could use a between date lookup and hope that
the user gets the dates for the week right. But as I think about it, can I
set it up so that if the user puts in a date, any date the query would pull
all the records that fall on that calander week?

So for this week if the user puts in 11 Jan 05 the query would get all the
dates 10 - 16 Jan 05?

Any help would be great

Take your pick:

WHERE DatePart("ww",[ADate])=DatePart("ww",[Enter a date]) AND
Year([ADate])=Year([Enter a date])

or...

WHERE Format([ADate],"ww yyyy")=Format([Enter a date],"ww yyyy")
 
I cant input this code I keep getting a invalid syntext. It looks like it is
looking at the first format in the code.

WHERE Format([ADate],"ww yyyy")=Format([Enter a date],"ww yyyy")

An alternative (one which will use indexes and not care about the
year):

BETWEEN DateAdd("d", 1-WeekDay(CDate([Enter a date:])), CDate([Enter a
date:]) AND DateAdd("d", 8-WeekDay(CDate([Enter a date:])),
CDate([Enter a date:])

John W. Vinson[MVP]
 
Back
Top