We help IT Professionals succeed at work.

Add days to date

Cyprexx IT
Cyprexx IT asked
on
I'm trying to figure out how to add days to a date in vba..

it cannot exclude weekends and holidays, it must count +17 complete days.\

thanks
Comment
Watch Question

BRONZE EXPERT
Top Expert 2016

Commented:

  dateadd("d", 17, [DateField])

to add 17 days to todays date

  dateadd("d", 17, Date())
Guy Hengel [angelIII / a3]Billing Engineer
GOLD EXPERT
Most Valuable Expert 2014
Top Expert 2009

Commented:
you mean dateadd("d", 17, yourdate) ?
http://www.techonthenet.com/excel/formulas/dateadd.php
BRONZE EXPERT
Top Expert 2016

Commented:
you can also do this  
     date() +17

Author

Commented:
I mean like, when I click on text field AuctionDate I want it to take PublishedDate field and add +17 days and display it in AuctionDate field.


Private Sub AuctionDate_Click()
Me.PublishedDate = DateAdd("d", 17, [AuctionDate])
Me.Recalc
End Sub


Trying to accomplish that

BRONZE EXPERT
Top Expert 2016

Commented:


Private Sub AuctionDate_Click()
Me.AuctionDate = DateAdd("d", 17, [PublishedDate])
Me.Recalc
End Sub
BRONZE EXPERT
Top Expert 2016
Commented:
or

Private Sub AuctionDate_Click()
Me.AuctionDate = DateAdd("d", 17, Me.[PublishedDate])
Me.Recalc
End Sub
SILVER EXPERT
Most Valuable Expert 2012
Top Expert 2013

Commented:
Generally calculated values like that shouldn't be stored in your tables. It creates redundant data, and can complicate things if a field that the calculation is based on changes.

With that understood, if you use this in the control source property of your AuctionDate textbox, it will display the value, and automatically change if PublishedDate changes:

= DateAdd("d", 17, [PublishedDate])

(Include the = sign in your control source)

Explore More ContentExplore courses, solutions, and other research materials related to this topic.