Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DateAdd Function

Status
Not open for further replies.

tziviak

Technical User
Oct 10, 2002
128
US
my dateAdd function is not working properly-when I add one to 9/30/03 I get 31 instead of 1(for october)

my code is (in a control source of a textbox) :

=IIf(Month([txt1])<>Month(DateAdd(&quot;d&quot;,1,[txt1])),Null,Day(DateAdd(&quot;d&quot;,1,[txt1])))

any ideas?
 
Sure!

Because you are only adding to the day of the month and not to the date

what is the value of txt1?
 
no it's actually a date also-that's derived from another place-but I realized you can't carry the chain so long-so I have to calcualte all my dates-from one original date (if you understand what I'm saying)
thanks anyway for replying
 
I tested your function and it works fine

Check this out

Dim Msg, IntervalType, Number, FirstDate

IntervalType = &quot;d&quot; ' &quot;d&quot; specifies months as interval.
FirstDate = InputBox(&quot;Enter a date&quot;)
Number = InputBox(&quot;Enter number of months to add&quot;)
Msg = &quot;New date: &quot; & DateAdd(IntervalType, Number, FirstDate)
MsgBox Msg
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top