Sep 16, 2003 #1 ghost2 Programmer Joined Aug 7, 2003 Messages 145 Location US I am trying to add + 1 to a date and in VB.Net it does not like it. How can I add 1 day to a date variable? Thanks all
I am trying to add + 1 to a date and in VB.Net it does not like it. How can I add 1 day to a date variable? Thanks all
Sep 16, 2003 #2 kmcdonag Programmer Joined Jul 24, 2003 Messages 15 Location US Use the add hours function to add 24 hours to the date dim d as date=#01/01/2004# private sub addDay ' Increment date by one day d=d.addhours(24) end sub Upvote 0 Downvote
Use the add hours function to add 24 hours to the date dim d as date=#01/01/2004# private sub addDay ' Increment date by one day d=d.addhours(24) end sub
Sep 16, 2003 #3 chiph Programmer Joined Jun 9, 1999 Messages 9,878 Location US You can also do it like this: Code: Dim MyDate As New DateTime(1963, 11, 22) Dim MyTimeSpan as New TimeSpan(1, 0, 0, 0) Dim MyNewDate as New DateTime MyNewDate = MyDate.Add(MyTimeSpan) If you were in C#, you could use the addition operator (+) to add the timespan to your datetime value: Code: MyNewDate = MyDate + MyTimeSpan; Chip H. If you want to get the best response to a question, please check out FAQ222-2244 first Upvote 0 Downvote
You can also do it like this: Code: Dim MyDate As New DateTime(1963, 11, 22) Dim MyTimeSpan as New TimeSpan(1, 0, 0, 0) Dim MyNewDate as New DateTime MyNewDate = MyDate.Add(MyTimeSpan) If you were in C#, you could use the addition operator (+) to add the timespan to your datetime value: Code: MyNewDate = MyDate + MyTimeSpan; Chip H. If you want to get the best response to a question, please check out FAQ222-2244 first