Date

Field: static readonly Date MinValue

It is the smallest default date (01.01.1753) value.


Field: static readonly Date MaxValue

It is the biggest default date (31.12.9999) value.


Method: static Date Parse(String)

The string data in yyyyMMdd format is converted to the Date object. See for more information: Parsing Date and Time Strings in .NET

    Date date = Date.Parse("20170807");
Parameter Name Description
dateString It is the Date information in the string type. It must be inyyyyMMdd format.

Error Type: FormatException (This error is thrown If dateString is not in yyyyMMdd format)


Constructor(Int32, Int32, Int32)

The Date object is created with day, month and year information.

Parameter Name Description
year Year information in int type.
month Month information in int type.
day Day information in int type.

Property: DateTime Value

Returns the date information in DateTime type.

The return value is the default time(00:00:00).

    new Date(2017,8,7).Value; // 8/7/2017 00:00:00

Method: DateTime ToDateTime()

Returns the date information in DateTime type.

The return value is the default time(00:00:00).

    new Date(2017,8,7).Value; // 8/7/2017 00:00:00

Method: DateTime ToDateTime(Time)

Returns the DateTime type by adding time information to Date information.

    new Date(2017,8,7).ToDateTime(new Time(9,30,0)); // 8/7/2017 09:30:00

Time information in Time type.


Method: Date Add(TimeSpan)

It adds time information and returns the Date in the data type.

    new Date(2017,8,7).Add(new TimeSpan(9,30,0)); // 8/7/2017
Parameter Name Description
timeSpan Time information in TimeSpan type.

Method: Date AddDays(Int32)

Adds day to the Date Data.

    new Date(2017,8,7).AddDays(3); // 8/10/2017
Parameter Name Description
days Days information in int type

Method: Date AddMonths(Int32)

Adds month to the Date Data.

    new Date(2017,8,7).AddMonth(3); //11/7/2017
Parameter Name Description
months Months information in int type

Method: Date AddYears(Int32)

Adds year to the Date Data.

    new Date(2017,8,7).AddYear(3); //8/7/2020
Parameter Name Description
years Years information in int type

Method: TimeSpan Subtract(Date)

Returns the time difference between the data and the given date in the TimeSpan type.

    new Date(2017,8,7).Subtract(new Date(2017,8,5).Add(new TimeSpan(12,0,0))); //1.12:00:00
Parameter Name Description
other Date information in Date type

Method: TimeSpan Subtract(TimeSpan)

Returns the time difference between the data and the time in the TimeSpan type, in the Date type.

    new Date(2017,8,7).Subtract(new TimeSpan(2,12,0,0)); //8/4/2017
Parameter Name Description
timeSpan Date information in Date type

Property: int Day

Returns the day value of the given int type.

    new Date(2017,8,7).Day; // 7

Property: DayOfWeek DayOfWeek

Returns the DayOfWeek type which is the day of the week.

    new Date(2017,8,7).DayOfWeek; // Monday

Property: int DayOfYear

Returns the int type which is the day of the year.

    new Date(2017,8,7).DayOfYear; // 219

Property: int Month

Returns the int type which is the month of the year.

    new Date(2017,8,7).Month; // 8

Property: int Year

Returns year value as int type

    new Date(2017,8,7).Year; // 2017

Property: Date FirstDay

Returns the first day of the month specified by the Date type.

    new Date(2017,8,7).FirstDay; // 8/1/2017

Property: Date LastDay

Returns the last day of the month specified by the Date type.

    new Date(2017,8,7).LastDay; // 8/31/2017

Property: Date NextMonth

The specified month returns an increment.

    new Date(2017,8,7).NextMonth; // 9/7/2017

Property: Date PreviousMonth

The specified month returns an decreased.

    new Date(2017,8,7).PreviousMonth; // 7/7/2017

Method: string ToString()

Returns the data in yyyyMMdd format and string type.

    new Date(2017,8,7).ToString(); // 20170807

Method: int CompareTo(Object)

The data is compared with the given object.

The given object must be a Date object.

If the data is less than the value in the given object, -1 is returned

If the data is equals to the value in the given object, 0 is returned

If the data is greater than the value in the given object, -1 is returned

    new Date(2017,8,7).CompareTo(new Date(2017,8,8)); //-1
    new Date(2017,8,7).CompareTo(new Date(2017,8,7)); //0
    new Date(2017,8,7).CompareTo(new Date(2017,8,5)); //1
Parameter Name Description
obj object to be compared

Error Type: ArgumentException (This error is thrown if given object is not in Date type.)


Method: int CompareTo(Date)

The data is compared with the given object.

If the data is less than the value in the given object, -1 is returned

If the data is equals to the value in the given object, 0 is returned

If the data is greater than the value in the given object, -1 is returned

Parameter Name Description
other karşılaştırılacak nesne

Method: bool Equals(Object)

Returns true if the given object has the same value as the Date object and the data, false otherwise.

Parameter Name Description
obj Object to be compared

Method: bool Equals(Date)

Returns true if the given Date object has the same value as the data, false otherwise.

Parameter Name Description
other The object of type Date to be compared

Extension Method: Date ToDate(DateTime)

Returns the date information in Date type.

Parameter Name Description
source It is the date information in DateTime type