Date calculations.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

In VB6.0 I Did This operation with dates.
Dim d as String
D=Date
D=D-1

or
D=D+1

In Vb.2003
Dim d As String
d = Microsoft.VisualBasic.Today.Date-1
and I received a error.
Who this work in Vb.2003?

Thanks.
 
You need to use the DateAdd() function (in Microsoft.VisualBasic namespace) ...

Dim d As Date
d = DateAdd(Microsoft.VisualBasic.DateInterval.Day, 1, Date.Now)
 
Or you can use some of the built in methods of the DateTime structure:

Dim d As Date = DateTime.Now

d = d.AddSeconds(10) 'Advances the datetime by 10 seconds
d = d.AddHours(1) 'Advances the datetime by 1 hour
d = d.AddDays(1) 'Advances the date by 1 day
d = d.AddDays(-1) 'Decreases the date by 1 day
 
Back
Top