DatePart Function In VB>NET

How is DatePart Function used?

Explanation

DatePart Function

DatePart Function in Visual Basic.net 2008 returns an integer value containing the specified component of the Date value.
Syntax:

DatePart(interval,date)
Example:

Module Module1
Sub Main()
Console.WriteLine("The date part of '01/10/2010' is::"
& DatePart("d", "01/10/2010"))
Console.ReadLine()
End Sub
End Module
Result:

The date part of '01/10/2010' is:: 10

In the above DatePart Function example, the date value entered is in the mm:dd:yy format, so the date returned is 10.

Visual Basic Tutorial


Ask Questions

Ask Question