different program lengths. (2weeks / 4weeks etc). i'm wanting to automatically input the dates working back from the delivery date only using workdays (Mon-Fri) based on which program has been selected
NumberOfIntervals = 5 * ProgramLength 'In 5 day weeks
DesiredDate = DateDif("w", (-1) * NumberOfIntervals, DeliveryDate)
' "w" for Workdays, (-1) * to Subract.
Set Delivery Date to n weeks from Today, where Program Length value = n
NumberOfIntervals = ProgramLength 'In weeks
DeliveryDate = DateDif("ww", NumberOfIntervals, Date)
' "ww" for calendar weeks.
The
interval argument has these settings:
Setting |
Description |
yyyy |
Year |
q |
Quarter |
m |
Month |
y |
Day of year |
d |
Day |
w |
Weekday |
ww |
Week |
h |
Hour |
n |
Minute |
s |
Second |
Remarks
You can use the
DateAdd function to add or subtract a specified time interval from a date. For example, you can use
DateAdd to calculate a date 30 days from today or a time 45 minutes from now.