VB date add

In VB, you can use the DateAdd(Interval, value,date) function of DateAndTime module to add a specify time interval to date.
-Interval can be DateInterval.Date (4), DateInterval.DateOfYear (3), DateInterval.Hour (7), DateInterval.Minute (8), DateInterval.Month (2), DateInterval.Quater (1), DateInterval.Second (9), DateInterval.Weekday (6), DateInterval. WeekOfYear (5), DateInterval.Year (0).
-value is the number that indicates the time interval to be added to the date
-date is the date value that the time interval will be added to.

For example, if you want to add 10 days (time interval) to the current date, the value of interval that you will have to specify is DateInterval.Day or 4.

Module Module1

   Sub Main()
     Dim dt = DateAdd(DateInterval.Day, 10, Now)
     Console.WriteLine("The date calculated 10 days from now is: " + dt)

     Console.Read()

   End Sub
End Module

Posted by: Ly | post date: 02-18-2013 | Subject: VB.NET Programming Language




This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.