Determine a date programmatically

G

GDub

May I get an assist or be pointed to a site (preferably
the former) that will tell me how to code a field to
display the last Monday date in May of any given current
year?

Thank you.
 
R

Roger Carlson

Exactly how do you want to "give" the year? The following in a control will
return the correct date for any hard-coded year.
=DateDiff("d",Weekday(#5/31/2008#-1,2),#5/31/2008#)
If you have a date field in a control on the form, you could replace the
control in the line like this:
=DateDiff("d",Weekday([TheDateField]-1,2), [TheDateField])
If you are doing it in a query and have a date field for the proper year,
you can do this:
LastMonday: DateDiff("d",Weekday([TheDateField]-1,2), [TheDateField])
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top