asp.net.ph

DateTime.Year Property

System Namespace   DateTime Structure


Returns the year component of the date represented by this instance.

[ VB ]
<Serializable>
Public ReadOnly Property Year As Integer

[ C# ]
[ Serializable ]
public int Year { get; }

[ C++ ]
[ Serializable ]
public: __property int get_Year ( );

[ JScript ]
public Serializable
function get Year ( ) : int;

Property Value

The year, between 1 and 9999.

Example

The below code snippet demonstrates using the Year property.

[ VB ]
Dim moment As New System.DateTime ( 1999, 1, 13, 3, 57, 32, 11 )

' Year gets 1999.
Dim year As Integer = moment.Year

' Month gets 1 ( January ).
Dim month As Integer = moment.Month

' Day gets 13.
Dim day As Integer = moment.Day

' Hour gets 3.
Dim hour As Integer = moment.Hour

' Minute gets 57.
Dim minute As Integer = moment.Minute

' Second gets 32.
Dim second As Integer = moment.Second

' Millisecond gets 11.
Dim millisecond As Integer = moment.Millisecond

[ C# ]
System.DateTime moment = new System.DateTime (
                        1999, 1, 13, 3, 57, 32, 11 );
// Year gets 1999.
int year = moment.Year;

// Month gets 1 ( January ).
int month = moment.Month;

// Day gets 13.
int day = moment.Day;

// Hour gets 3.
int hour = moment.Hour;

// Minute gets 57.
int minute = moment.Minute;

// Second gets 32.
int second = moment.Second;

// Millisecond gets 11.
int millisecond = moment.Millisecond;
See Also

DateTime Members   Int32   Calendar Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph