Querying Dates

  • Thread starter Thread starter Serene
  • Start date Start date
S

Serene

I have a table with week ending dates in it along with
other data relevent to the paticular week ending date.
Each week ending date is an individual record. What I
want to be able to is have a query that when it runs it
selects the relevent week ending record for the week that
we are currently in. I assume it will be based on
the "Date()".

Can anyone help please?
 
I have a table with week ending dates in it along with
other data relevent to the paticular week ending date.
Each week ending date is an individual record. What I
want to be able to is have a query that when it runs it
selects the relevent week ending record for the week that
we are currently in. I assume it will be based on
the "Date()".

Can anyone help please?

Assuming that the "week ending date" is the coming Saturday, or today
if you run the query on Saturday, try a criterion on the field of

DateAdd("d", 7 - DatePart("w", Date(), vbSunday), Date())

DatePart will return 1 for Sunday, 2 for Monday, ... 7 for Friday;
DateAdd will add enough days to Date() to bring it up to the next
Saturday. Use vbSaturday as the "start of the week" argument if your
week ends on Friday, etc.
 
Thanks all for your assistance
-----Original Message-----
Try:
DLookup("YourDateField", "YourTable", "YourDateField
= Date()")

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.




.
 
Back
Top