472,146 Members | 1,395 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,146 software developers and data experts.

VB.Net 2003 DateAdd Function

Does subject VB.net 2003 support DateAdd function? I have tried to
implement the following without success. In my example I tried to
simply add 30 months to 9/18/2003 and I get "New date: 12:00:00 AM",
no date
Example direct from VB Language Reference:

Public Overloads Function DateAdd(ByVal Interval As DateInterval,_
ByVal Number As Double, ByVal DateValue As DateTime) As DateTime
End Function

Private Sub Button2_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button2.Click
Dim Msg, Number, StartDate As String
Dim Months As Double
Dim SecondDate As Date
Dim IntervalType As DateInterval
IntervalType = DateInterval.Month
StartDate = InputBox("Enter a Date")
SecondDate = CDate(StartDate)
Number = InputBox("Enter number of months to add") 'Input
Number of Added Months
Months = Val(Number)
Msg = "New date " & DateAdd(IntervalType, Number, SecondDate)
MsgBox(Msg)

Any Comments or suggestions welcomed
Thanks.
A retired EE and very novice programmer.
Nov 20 '05 #1
1 18888
"C.Davidson" <cw***@swbell.net> schrieb
Does subject VB.net 2003 support DateAdd function? I have tried
to implement the following without success. In my example I tried
to simply add 30 months to 9/18/2003 and I get "New date: 12:00:00
AM", no date
Example direct from VB Language Reference:

Public Overloads Function DateAdd(ByVal Interval As DateInterval,_
ByVal Number As Double, ByVal DateValue As DateTime) As DateTime
End Function

Private Sub Button2_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button2.Click
Dim Msg, Number, StartDate As String
Dim Months As Double
Dim SecondDate As Date
Dim IntervalType As DateInterval
IntervalType = DateInterval.Month
StartDate = InputBox("Enter a Date")
SecondDate = CDate(StartDate)
Number = InputBox("Enter number of months to add") 'Input
Number of Added Months
Months = Val(Number)
Msg = "New date " & DateAdd(IntervalType, Number,
SecondDate) MsgBox(Msg)

Any Comments or suggestions welcomed
Thanks.
A retired EE and very novice programmer.


Your function 'DateAdd' does nothing. I'd use the already existing DateAdd
function.
--
Armin

Nov 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Zlatko Matić | last post: by
2 posts views Thread by Abdul N K | last post: by
4 posts views Thread by ey.markov | last post: by
reply views Thread by Zlatko Matić | last post: by
2 posts views Thread by Rich Raffenetti | last post: by
3 posts views Thread by Mel | last post: by
reply views Thread by Saiars | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.