Determine a date programmatically

  • Thread starter Thread starter GDub
  • Start date Start date
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.
 
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])
 
Back
Top