How to perform date arithemetic

jeboy

Member
Joined
Nov 19, 2006
Messages
21
Programming Experience
Beginner
How can I know if the present date is less than or greater than the specified date?
For example:
July 1, 2007 > August 16, 2007

How can I add days to a date?
For example:
July 1, 2007 + 24 days = July 25, 2007
 
Dim dtA AsDate = DateSerial(2007, 7, 1)
Dim dtB AsDate = DateSerial(2007, 8, 16)

The preferred way to make a date object in .NET is to use the DateTime(int, int, int) constructor:

DateTime dtA = new DateTime(2007, 8, 16)


Try to avoid using the legacy VB6 functions if possible - they reduce a programmers ability to read other .NET syntaxes and exist largely as mapping functions to allow old VB6 code to be pasted into VB.NET apps and have a small hope of working correctly (and a larger hope of being not-too-broken)

Legacy functions, for the most part, can be identified by: being functions in vb6, belonging to the Microsoft.VisualBasic namespace. They wrap the more modern, better formed .NET counterparts found throughout the framework
 
Back
Top