DateSerial Function In VB.NET
How to use DateSerial Function?
Explanation
DateSerial Function
DateSerial Function in Visual Basic.net 2008 returns an date value for the specified year, month and day with the
time set to the midnight. If the month value is '0' or '-1' the month december or november of the previous year is taken.
If the month value is '1', january month of the calculated year is taken, if '13' january of the
following year is taken.
If the Day value is '1' refers to the first day of the calculated month, '0' for the last day of previous month, '-1'
the penultimate day of the previous month.
Syntax:
DateSerial(Year,Month,Day)
Example:
Module Module1
Sub Main()
Dim a As Date
a = DateSerial(2010, 2, 21)
Console.WriteLine(a)
Console.ReadLine()
End Sub
End Module
Result:
2/21/2010 12:00:00 AM
In the above DateSerial Function example, the date value entered is displayed with the time set to the midnight using the
DateSerial().