- 13 Dec 2023
- 1 Minute to read
- DarkLight
Date-Time
- Updated on 13 Dec 2023
- 1 Minute to read
- DarkLight
General
Values of type DateTime (alternativly named Date) can hold dates or date-times. A detailed explanation of the data-type can be found in the Date Data-Type article of the Visual Basic .NET language documentation.
Constants
Constant date-time values are written using the following syntax:
#8/13/2002 12:14 PM#
You can also only specify a date:
#8/13/2002#
To access the current date-time, you can use the following expression:
DateTime.Now
To access the current date, you can use the following expression:
Date.Today
To access the current date-time, you can use the following expression:
DateTime.Now
Calculations
AddDays
The AddDays function returns a date that has the provided number of days added or subtracted; the following expression returns the date for yesterday:
Date.Today.AddDays(-1)
AddMonths
The AddMonths function returns a date that has the provided number of months added or subtracted; the following expression returns today minus 1 month:
Date.Today.AddMonths(-1)