Show / Hide Table of Contents

Class DateTimeEx

Class containing some extension methods for System.DateTime.

Inheritance
System.Object
DateTimeEx
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace:Extend
Assembly:Extend.dll
Syntax
public static class DateTimeEx

Methods

| Improve this Doc View Source

Age(DateTime, Nullable<DateTime>)

Calculates the difference between the year of the current and the given date time.

Declaration
public static int Age(this DateTime dateTime, DateTime? now = null)
Parameters
Type Name Description
System.DateTime dateTime

The date time value.

System.Nullable<T><System.DateTime> now

The 'current' date used to calculate the age, or null to use System.DateTime.Now.

Returns
Type Description
System.Int32

The difference between the year of the current and the given date time.

Remarks

now can be smaller than dateTime, which results in negative results. Source from: http://stackoverflow.com/questions/9/how-do-i-calculate-someones-age-in-c

| Improve this Doc View Source

Elapsed(DateTime)

Calculates the elapsed time between the given date time value and DateTime.Now.

Declaration
public static TimeSpan Elapsed(this DateTime dateTime)
Parameters
Type Name Description
System.DateTime dateTime

The date time value.

Returns
Type Description
System.TimeSpan

Returns the elapsed time between the given date time value and DateTime.Now.

| Improve this Doc View Source

EndOfDay(DateTime)

Returns the last moment of the day ("23:59:59:999") represented by the given date time value.

Declaration
public static DateTime EndOfDay(this DateTime day)
Parameters
Type Name Description
System.DateTime day

The day to get the end of.

Returns
Type Description
System.DateTime

Returns the last moment of the day ("23:59:59:999") represented by the given date time value.

| Improve this Doc View Source

EndOfMonth(DateTime)

Returns the last moment ("23:59:59:999") of the month represented by the given date time value.

Declaration
public static DateTime EndOfMonth(this DateTime month)
Parameters
Type Name Description
System.DateTime month

The @this to act on.

Returns
Type Description
System.DateTime

Returns the last moment ("23:59:59:999") of the month represented by the given date time value.

| Improve this Doc View Source

EndOfWeek(DateTime, DayOfWeek)

Returns the last day of the current week. Note: This method uses the given day as last day of the week. Default is Sunday.

Declaration
public static DateTime EndOfWeek(this DateTime week, DayOfWeek lastDayOfWeek = DayOfWeek.Sunday)
Parameters
Type Name Description
System.DateTime week

The week to return the end of.

System.DayOfWeek lastDayOfWeek

The last day of the week. Default is Sunday.

Returns
Type Description
System.DateTime

Returns the last day of the current week.

| Improve this Doc View Source

EndOfYear(DateTime)

Returns the last moment ("23:59:59:999") of the year represented by the given date time.

Declaration
public static DateTime EndOfYear(this DateTime year)
Parameters
Type Name Description
System.DateTime year

The year to return the end of.

Returns
Type Description
System.DateTime

Returns the last moment ("23:59:59:999") of the year represented by the given date time.

| Improve this Doc View Source

FirstDayOfWeek(DateTime)

Returns the first day of the week, represented by the given date time.

Declaration
public static DateTime FirstDayOfWeek(this DateTime week)
Parameters
Type Name Description
System.DateTime week

The week to return the first day of.

Returns
Type Description
System.DateTime

Returns the first day of the week, represented by the given date time.

| Improve this Doc View Source

GetWeekOfYear(DateTime)

Gets the week-number of the given date-time value.

Declaration
public static int GetWeekOfYear(this DateTime dateTime)
Parameters
Type Name Description
System.DateTime dateTime

The date-time value.

Returns
Type Description
System.Int32

Returns the number of the given week.

Remarks

This implementation is ISO 8601 compatible see: https://en.wikipedia.org/wiki/ISO_8601. For .Net details see: http://stackoverflow.com/questions/11154673/get-the-correct-week-number-of-a-given-date This presumes that weeks start with Monday. Week 1 is the 1st week of the year with a Thursday in it.

| Improve this Doc View Source

Intersects(DateTime, DateTime, DateTime, DateTime)

Checks if the two date ranges intersects.

Declaration
public static bool Intersects(this DateTime startDate, DateTime endDate, DateTime intersectingStartDate, DateTime intersectingEndDate)
Parameters
Type Name Description
System.DateTime startDate

The start date.

System.DateTime endDate

The end date.

System.DateTime intersectingStartDate

The intersecting start date.

System.DateTime intersectingEndDate

The intersecting end date.

Returns
Type Description
System.Boolean

Returns true if the two date ranges intersects, otherwise false.

| Improve this Doc View Source

IsAfternoon(DateTime)

Checks whether the given date time value is at afternoon or not.

Declaration
public static bool IsAfternoon(this DateTime dateTime)
Parameters
Type Name Description
System.DateTime dateTime

The date time to check.

Returns
Type Description
System.Boolean

Returns true if the date time value is at afternoon, otherwise false.

| Improve this Doc View Source

IsFuture(DateTime)

Checks if the date time value is in the future.

Declaration
public static bool IsFuture(this DateTime dateTime)
Parameters
Type Name Description
System.DateTime dateTime

The @date time to check.

Returns
Type Description
System.Boolean

Returns true if the value is in the future, otherwise false.

| Improve this Doc View Source

IsLastDayOfMonth(DateTime)

Gets a value indicating whether the given date-time value is the last day of the month represented in dateTime.

Declaration
public static bool IsLastDayOfMonth(this DateTime dateTime)
Parameters
Type Name Description
System.DateTime dateTime

The date-time value.

Returns
Type Description
System.Boolean

Returns a value of true if the given date-time value is the last day of the month.

| Improve this Doc View Source

IsMorning(DateTime)

Checks is the date time value is morning.

Declaration
public static bool IsMorning(this DateTime dateTime)
Parameters
Type Name Description
System.DateTime dateTime

The date time to check.

Returns
Type Description
System.Boolean

Returns true if the date time is morning, otherwise false.

| Improve this Doc View Source

IsPast(DateTime)

Checks if the date time value is in the past.

Declaration
public static bool IsPast(this DateTime dateTime)
Parameters
Type Name Description
System.DateTime dateTime

The date time to check.

Returns
Type Description
System.Boolean

Returns true if the value is in the past, otherwise false.

| Improve this Doc View Source

IsSameDay(DateTime, DateTime)

Gets whether the given date-time values are the same day.

Declaration
public static bool IsSameDay(this DateTime dateTime, DateTime otherDateTime)
Parameters
Type Name Description
System.DateTime dateTime

The first date-time value.

System.DateTime otherDateTime

The second date-time value.

Returns
Type Description
System.Boolean

Returns true if the given date-time values are the same day, otherwise false.

| Improve this Doc View Source

IsSameMonthAndYear(DateTime, DateTime)

Gets whether the given date-time values are the same month and year.

Declaration
public static bool IsSameMonthAndYear(this DateTime dateTime, DateTime otherDateTime)
Parameters
Type Name Description
System.DateTime dateTime

The first date-time value.

System.DateTime otherDateTime

The second date-time value.

Returns
Type Description
System.Boolean

Returns true if the given date-time values are the same month and year, otherwise false.

| Improve this Doc View Source

IsTimeEquals(DateTime, DateTime)

Checks if the time is equals to the given time.

Declaration
public static bool IsTimeEquals(this DateTime time, DateTime timeToCompare)
Parameters
Type Name Description
System.DateTime time

The time to check.

System.DateTime timeToCompare

The time to compare.

Returns
Type Description
System.Boolean

Returns true if the time is equals, otherwise false.

| Improve this Doc View Source

IsToday(DateTime)

Checks if the given date time is today.

Declaration
public static bool IsToday(this DateTime dateTime)
Parameters
Type Name Description
System.DateTime dateTime

The date time to check.

Returns
Type Description
System.Boolean

Returns true if the date time value is today, otherwise false.

| Improve this Doc View Source

IsWeekdDay(DateTime)

Checks if the given day is a week day (MOnday - Friday).

Declaration
public static bool IsWeekdDay(this DateTime day)
Parameters
Type Name Description
System.DateTime day

The day to check.

Returns
Type Description
System.Boolean

Returns true if the day is a week day, otherwise false.

| Improve this Doc View Source

IsWeekendDay(DateTime)

Checks if the given day is a weekend day (Saturday or Sunday).

Declaration
public static bool IsWeekendDay(this DateTime day)
Parameters
Type Name Description
System.DateTime day

The day to check.

Returns
Type Description
System.Boolean

Returns true if the day is a weekend day, otherwise false.

| Improve this Doc View Source

LastDayOfWeek(DateTime)

Returns the last day of the given week.

Declaration
public static DateTime LastDayOfWeek(this DateTime week)
Parameters
Type Name Description
System.DateTime week

The week to get the last day of.

Returns
Type Description
System.DateTime

Returns the last day of the given week.

| Improve this Doc View Source

NextMonthStart(DateTime)

Returns the first day of the next month, based on the given date-time value.

Declaration
public static DateTime NextMonthStart(this DateTime dateTime)
Parameters
Type Name Description
System.DateTime dateTime

The date-time value.

Returns
Type Description
System.DateTime

Returns the first day of the next month, based on the given date-time value.

| Improve this Doc View Source

NextWeekDay(DateTime)

Gets the next week day, based on the given day.

Declaration
public static DateTime NextWeekDay(this DateTime day)
Parameters
Type Name Description
System.DateTime day

The day.

Returns
Type Description
System.DateTime

Returns the next week day (can be day if the given day is a week day).

| Improve this Doc View Source

StartOfDay(DateTime)

Returns the start of the given day ("00:00:00:000").

Declaration
public static DateTime StartOfDay(this DateTime day)
Parameters
Type Name Description
System.DateTime day

The day to get the start of.

Returns
Type Description
System.DateTime

Returns the start of the given day ("00:00:00:000").

| Improve this Doc View Source

StartOfMonth(DateTime)

Returns the start of the given month (with time set to "00:00:00:000").

Declaration
public static DateTime StartOfMonth(this DateTime month)
Parameters
Type Name Description
System.DateTime month

The month to get the start of.

Returns
Type Description
System.DateTime

Returns the start of the given month (with time set to "00:00:00:000").

| Improve this Doc View Source

StartOfWeek(DateTime, DayOfWeek)

Returns the first day of the current week. Note: This method uses the given day as first day of the week. Default is Monday.

Declaration
public static DateTime StartOfWeek(this DateTime week, DayOfWeek firstDayOfWeek = DayOfWeek.Monday)
Parameters
Type Name Description
System.DateTime week

The week to return the start of.

System.DayOfWeek firstDayOfWeek

The first day of the week. Default is Monday.

Returns
Type Description
System.DateTime

Returns the first day of the current week.

| Improve this Doc View Source

StartOfYear(DateTime)

Returns the start of the given year with time set to "00:00:00:000".

Declaration
public static DateTime StartOfYear(this DateTime year)
Parameters
Type Name Description
System.DateTime year

The year to get the start of.

Returns
Type Description
System.DateTime

Returns the start of the given year with time set to "00:00:00:000".

| Improve this Doc View Source

ToFullDateTimeString(DateTime)

Converts the DateTime value to a full date time string.

Declaration
public static string ToFullDateTimeString(this DateTime dateTime)
Parameters
Type Name Description
System.DateTime dateTime

The DateTime value to convert.

Returns
Type Description
System.String

The given value converted to a full date time string.

| Improve this Doc View Source

ToFullDateTimeString(DateTime, CultureInfo)

Converts the DateTime value to a full date time string.

Declaration
public static string ToFullDateTimeString(this DateTime dateTime, CultureInfo culture)
Parameters
Type Name Description
System.DateTime dateTime

The DateTime value to convert.

System.Globalization.CultureInfo culture

The culture.

Returns
Type Description
System.String

The given value converted to a full date time string.

Exceptions
Type Condition
System.ArgumentNullException

The culture can not be null.

| Improve this Doc View Source

ToFullDateTimeString(DateTime, DateTimeFormatInfo)

Converts the DateTime value to a full date time string.

Declaration
public static string ToFullDateTimeString(this DateTime dateTime, DateTimeFormatInfo formatInfo)
Parameters
Type Name Description
System.DateTime dateTime

The DateTime value to convert.

System.Globalization.DateTimeFormatInfo formatInfo

The date time format info.

Returns
Type Description
System.String

The given value converted to a full date time string.

Exceptions
Type Condition
System.ArgumentNullException

The format info can not be null.

| Improve this Doc View Source

ToLongDateShortTimeString(DateTime)

Converts the DateTime value to a long date short time string.

Declaration
public static string ToLongDateShortTimeString(this DateTime dateTime)
Parameters
Type Name Description
System.DateTime dateTime

The DateTime value to convert.

Returns
Type Description
System.String

The given value converted to a long date short time string.

| Improve this Doc View Source

ToLongDateShortTimeString(DateTime, CultureInfo)

Converts the DateTime value to a long date short time string.

Declaration
public static string ToLongDateShortTimeString(this DateTime dateTime, CultureInfo culture)
Parameters
Type Name Description
System.DateTime dateTime

The DateTime value to convert.

System.Globalization.CultureInfo culture

The culture.

Returns
Type Description
System.String

The given value converted to a long date short time string.

Exceptions
Type Condition
System.ArgumentNullException

The culture can not be null.

| Improve this Doc View Source

ToLongDateShortTimeString(DateTime, DateTimeFormatInfo)

Converts the DateTime value to a long date short time string.

Declaration
public static string ToLongDateShortTimeString(this DateTime dateTime, DateTimeFormatInfo formatInfo)
Parameters
Type Name Description
System.DateTime dateTime

The DateTime value to convert.

System.Globalization.DateTimeFormatInfo formatInfo

The date time format info.

Returns
Type Description
System.String

The given value converted to a long date short time string.

Exceptions
Type Condition
System.ArgumentNullException

The format info can not be null.

| Improve this Doc View Source

ToLongDateString(DateTime)

Converts the DateTime value to a long date time string.

Declaration
public static string ToLongDateString(this DateTime dateTime)
Parameters
Type Name Description
System.DateTime dateTime

The DateTime value to convert.

Returns
Type Description
System.String

The given value converted to a long date time string.

| Improve this Doc View Source

ToLongDateString(DateTime, CultureInfo)

Converts the DateTime value to a long date time string.

Declaration
public static string ToLongDateString(this DateTime dateTime, CultureInfo culture)
Parameters
Type Name Description
System.DateTime dateTime

The DateTime value to convert.

System.Globalization.CultureInfo culture

The culture.

Returns
Type Description
System.String

The given value converted to a long date time string.

Exceptions
Type Condition
System.ArgumentNullException

The culture can not be null.

| Improve this Doc View Source

ToLongDateString(DateTime, DateTimeFormatInfo)

Converts the DateTime value to a long date time string.

Declaration
public static string ToLongDateString(this DateTime dateTime, DateTimeFormatInfo formatInfo)
Parameters
Type Name Description
System.DateTime dateTime

The DateTime value to convert.

System.Globalization.DateTimeFormatInfo formatInfo

The date time format info.

Returns
Type Description
System.String

The given value converted to a long date time string.

Exceptions
Type Condition
System.ArgumentNullException

The format info can not be null.

| Improve this Doc View Source

ToLongTimeString(DateTime)

Converts the DateTime value to a long time string.

Declaration
public static string ToLongTimeString(this DateTime dateTime)
Parameters
Type Name Description
System.DateTime dateTime

The DateTime value to convert.

Returns
Type Description
System.String

The given value converted to a long time string.

| Improve this Doc View Source

ToLongTimeString(DateTime, CultureInfo)

Converts the DateTime value to a long time string.

Declaration
public static string ToLongTimeString(this DateTime dateTime, CultureInfo culture)
Parameters
Type Name Description
System.DateTime dateTime

The DateTime value to convert.

System.Globalization.CultureInfo culture

The culture.

Returns
Type Description
System.String

The given value converted to a long time string.

Exceptions
Type Condition
System.ArgumentNullException

The culture can not be null.

| Improve this Doc View Source

ToLongTimeString(DateTime, DateTimeFormatInfo)

Converts the DateTime value to a long time string.

Declaration
public static string ToLongTimeString(this DateTime dateTime, DateTimeFormatInfo formatInfo)
Parameters
Type Name Description
System.DateTime dateTime

The DateTime value to convert.

System.Globalization.DateTimeFormatInfo formatInfo

The date time format info.

Returns
Type Description
System.String

The given value converted to a long time string.

Exceptions
Type Condition
System.ArgumentNullException

The format info can not be null.

| Improve this Doc View Source

ToMonthDayString(DateTime)

Converts the DateTime value to a month day string.

Declaration
public static string ToMonthDayString(this DateTime dateTime)
Parameters
Type Name Description
System.DateTime dateTime

The DateTime value to convert.

Returns
Type Description
System.String

The given value converted to a month day string.

| Improve this Doc View Source

ToMonthDayString(DateTime, CultureInfo)

Converts the DateTime value to a month day string.

Declaration
public static string ToMonthDayString(this DateTime dateTime, CultureInfo culture)
Parameters
Type Name Description
System.DateTime dateTime

The DateTime value to convert.

System.Globalization.CultureInfo culture

The culture.

Returns
Type Description
System.String

The given value converted to a month day string.

Exceptions
Type Condition
System.ArgumentNullException

The culture can not be null.

| Improve this Doc View Source

ToMonthDayString(DateTime, DateTimeFormatInfo)

Converts the DateTime value to a month day string.

Declaration
public static string ToMonthDayString(this DateTime dateTime, DateTimeFormatInfo formatInfo)
Parameters
Type Name Description
System.DateTime dateTime

The DateTime value to convert.

System.Globalization.DateTimeFormatInfo formatInfo

The date time format info.

Returns
Type Description
System.String

The given value converted to a month day string.

Exceptions
Type Condition
System.ArgumentNullException

The format info can not be null.

| Improve this Doc View Source

ToMonthString(DateTime)

Converts the DateTime value to a month string.

Declaration
public static string ToMonthString(this DateTime dateTime)
Parameters
Type Name Description
System.DateTime dateTime

The DateTime value to convert.

Returns
Type Description
System.String

The given value converted to a year month string.

| Improve this Doc View Source

ToMonthString(DateTime, CultureInfo)

Converts the DateTime value to a month string.

Declaration
public static string ToMonthString(this DateTime dateTime, CultureInfo culture)
Parameters
Type Name Description
System.DateTime dateTime

The DateTime value to convert.

System.Globalization.CultureInfo culture

The culture.

Returns
Type Description
System.String

The given value converted to a year month string.

Exceptions
Type Condition
System.ArgumentNullException

The culture can not be null.

| Improve this Doc View Source

ToMonthString(DateTime, DateTimeFormatInfo)

Converts the DateTime value to a month string.

Declaration
public static string ToMonthString(this DateTime dateTime, DateTimeFormatInfo formatInfo)
Parameters
Type Name Description
System.DateTime dateTime

The DateTime value to convert.

System.Globalization.DateTimeFormatInfo formatInfo

The date time format info.

Returns
Type Description
System.String

The given value converted to year month string.

Exceptions
Type Condition
System.ArgumentNullException

The format info can not be null.

| Improve this Doc View Source

Tomorrow(DateTime)

Adds a day to the given date time value.

Declaration
public static DateTime Tomorrow(this DateTime dateTime)
Parameters
Type Name Description
System.DateTime dateTime

The date time to increase.

Returns
Type Description
System.DateTime

Tomorrow date at same time.

| Improve this Doc View Source

ToShortDateLongTimeString(DateTime)

Converts the DateTime value to a short date long time string.

Declaration
public static string ToShortDateLongTimeString(this DateTime dateTime)
Parameters
Type Name Description
System.DateTime dateTime

The DateTime value to convert.

Returns
Type Description
System.String

The given value converted to a short date long time string.

| Improve this Doc View Source

ToShortDateLongTimeString(DateTime, CultureInfo)

Converts the DateTime value to a short date long time string.

Declaration
public static string ToShortDateLongTimeString(this DateTime dateTime, CultureInfo culture)
Parameters
Type Name Description
System.DateTime dateTime

The DateTime value to convert.

System.Globalization.CultureInfo culture

The culture.

Returns
Type Description
System.String

The given value converted to a short date long time string.

Exceptions
Type Condition
System.ArgumentNullException

The culture can not be null.

| Improve this Doc View Source

ToShortDateLongTimeString(DateTime, DateTimeFormatInfo)

Converts the DateTime value to a short date long time string.

Declaration
public static string ToShortDateLongTimeString(this DateTime dateTime, DateTimeFormatInfo formatInfo)
Parameters
Type Name Description
System.DateTime dateTime

The DateTime value to convert.

System.Globalization.DateTimeFormatInfo formatInfo

The date time format info.

Returns
Type Description
System.String

The given value converted to a short date long time string.

Exceptions
Type Condition
System.ArgumentNullException

The format info can not be null.

| Improve this Doc View Source

ToShortDateString(DateTime)

Converts the DateTime value to a short date string.

Declaration
public static string ToShortDateString(this DateTime dateTime)
Parameters
Type Name Description
System.DateTime dateTime

The DateTime value to convert.

Returns
Type Description
System.String

The given value converted to a short date string.

| Improve this Doc View Source

ToShortDateString(DateTime, CultureInfo)

Converts the DateTime value to a short date string.

Declaration
public static string ToShortDateString(this DateTime dateTime, CultureInfo culture)
Parameters
Type Name Description
System.DateTime dateTime

The DateTime value to convert.

System.Globalization.CultureInfo culture

The culture.

Returns
Type Description
System.String

The given value converted to a short date string.

Exceptions
Type Condition
System.ArgumentNullException

The culture can not be null.

| Improve this Doc View Source

ToShortDateString(DateTime, DateTimeFormatInfo)

Converts the DateTime value to a short date string.

Declaration
public static string ToShortDateString(this DateTime dateTime, DateTimeFormatInfo formatInfo)
Parameters
Type Name Description
System.DateTime dateTime

The DateTime value to convert.

System.Globalization.DateTimeFormatInfo formatInfo

The date time format info.

Returns
Type Description
System.String

The given value converted to a short date string.

Exceptions
Type Condition
System.ArgumentNullException

The format info can not be null.

| Improve this Doc View Source

ToShortDateTimeString(DateTime)

Converts the DateTime value to a short date time string.

Declaration
public static string ToShortDateTimeString(this DateTime dateTime)
Parameters
Type Name Description
System.DateTime dateTime

The DateTime value to convert.

Returns
Type Description
System.String

The given value converted to a short date time string.

| Improve this Doc View Source

ToShortDateTimeString(DateTime, CultureInfo)

Converts the DateTime value to a short date time string.

Declaration
public static string ToShortDateTimeString(this DateTime dateTime, CultureInfo culture)
Parameters
Type Name Description
System.DateTime dateTime

The DateTime value to convert.

System.Globalization.CultureInfo culture

The culture.

Returns
Type Description
System.String

The given value converted to a short date time string.

Exceptions
Type Condition
System.ArgumentNullException

The culture can not be null.

| Improve this Doc View Source

ToShortDateTimeString(DateTime, DateTimeFormatInfo)

Converts the DateTime value to a short date time string.

Declaration
public static string ToShortDateTimeString(this DateTime dateTime, DateTimeFormatInfo formatInfo)
Parameters
Type Name Description
System.DateTime dateTime

The DateTime value to convert.

System.Globalization.DateTimeFormatInfo formatInfo

The date time format info.

Returns
Type Description
System.String

The given value converted to a short date time string.

Exceptions
Type Condition
System.ArgumentNullException

The format info can not be null.

| Improve this Doc View Source

ToShortTimeString(DateTime)

Converts the DateTime value to a short time string.

Declaration
public static string ToShortTimeString(this DateTime dateTime)
Parameters
Type Name Description
System.DateTime dateTime

The DateTime value to convert.

Returns
Type Description
System.String

The given value converted to a short time string.

| Improve this Doc View Source

ToShortTimeString(DateTime, CultureInfo)

Converts the DateTime value to a short time string.

Declaration
public static string ToShortTimeString(this DateTime dateTime, CultureInfo culture)
Parameters
Type Name Description
System.DateTime dateTime

The DateTime value to convert.

System.Globalization.CultureInfo culture

The culture.

Returns
Type Description
System.String

The given value converted to a short time string.

Exceptions
Type Condition
System.ArgumentNullException

The culture can not be null.

| Improve this Doc View Source

ToShortTimeString(DateTime, DateTimeFormatInfo)

Converts the DateTime value to a short time string.

Declaration
public static string ToShortTimeString(this DateTime dateTime, DateTimeFormatInfo formatInfo)
Parameters
Type Name Description
System.DateTime dateTime

The DateTime value to convert.

System.Globalization.DateTimeFormatInfo formatInfo

The date time format info.

Returns
Type Description
System.String

The given value converted to a short time string.

Exceptions
Type Condition
System.ArgumentNullException

The format info can not be null.

| Improve this Doc View Source

ToSortableDateTimeString(DateTime)

Converts the DateTime value to a sortable date time string.

Declaration
public static string ToSortableDateTimeString(this DateTime dateTime)
Parameters
Type Name Description
System.DateTime dateTime

The DateTime value to convert.

Returns
Type Description
System.String

The given value converted to a sortable date time string.

| Improve this Doc View Source

ToSortableDateTimeString(DateTime, CultureInfo)

Converts the DateTime value to a sortable date time string.

Declaration
public static string ToSortableDateTimeString(this DateTime dateTime, CultureInfo culture)
Parameters
Type Name Description
System.DateTime dateTime

The DateTime value to convert.

System.Globalization.CultureInfo culture

The culture.

Returns
Type Description
System.String

The given value converted to a sortable date time string.

Exceptions
Type Condition
System.ArgumentNullException

The culture can not be null.

| Improve this Doc View Source

ToSortableDateTimeString(DateTime, DateTimeFormatInfo)

Converts the DateTime value to a sortable date time string.

Declaration
public static string ToSortableDateTimeString(this DateTime dateTime, DateTimeFormatInfo formatInfo)
Parameters
Type Name Description
System.DateTime dateTime

The DateTime value to convert.

System.Globalization.DateTimeFormatInfo formatInfo

The date time format info.

Returns
Type Description
System.String

The given value converted to a sortable date time string.

Exceptions
Type Condition
System.ArgumentNullException

The format info can not be null.

| Improve this Doc View Source

ToUniversalSortableDateTimeString(DateTime)

Converts the DateTime value to a universal sortable date time string.

Declaration
public static string ToUniversalSortableDateTimeString(this DateTime dateTime)
Parameters
Type Name Description
System.DateTime dateTime

The DateTime value to convert.

Returns
Type Description
System.String

The given value converted to a universal sortable date time string.

| Improve this Doc View Source

ToUniversalSortableDateTimeString(DateTime, CultureInfo)

Converts the DateTime value to a universal sortable date time string.

Declaration
public static string ToUniversalSortableDateTimeString(this DateTime dateTime, CultureInfo culture)
Parameters
Type Name Description
System.DateTime dateTime

The DateTime value to convert.

System.Globalization.CultureInfo culture

The culture.

Returns
Type Description
System.String

The given value converted to a universal sortable date time string.

Exceptions
Type Condition
System.ArgumentNullException

The culture can not be null.

| Improve this Doc View Source

ToUniversalSortableDateTimeString(DateTime, DateTimeFormatInfo)

Converts the DateTime value to a universal sortable date time string.

Declaration
public static string ToUniversalSortableDateTimeString(this DateTime dateTime, DateTimeFormatInfo formatInfo)
Parameters
Type Name Description
System.DateTime dateTime

The DateTime value to convert.

System.Globalization.DateTimeFormatInfo formatInfo

The date time format info.

Returns
Type Description
System.String

The given value converted to a universal sortable date time string.

Exceptions
Type Condition
System.ArgumentNullException

The format info can not be null.

| Improve this Doc View Source

ToUniversalSortableLongDateTimeString(DateTime)

Converts the DateTime value to a universal sortable long date time string.

Declaration
public static string ToUniversalSortableLongDateTimeString(this DateTime dateTime)
Parameters
Type Name Description
System.DateTime dateTime

The DateTime value to convert.

Returns
Type Description
System.String

The given value converted to a universal sortable long date time string.

| Improve this Doc View Source

ToUniversalSortableLongDateTimeString(DateTime, CultureInfo)

Converts the DateTime value to a universal sortable long date time string.

Declaration
public static string ToUniversalSortableLongDateTimeString(this DateTime dateTime, CultureInfo culture)
Parameters
Type Name Description
System.DateTime dateTime

The DateTime value to convert.

System.Globalization.CultureInfo culture

The culture.

Returns
Type Description
System.String

The given value converted to a universal sortable long date time string.

Exceptions
Type Condition
System.ArgumentNullException

The culture can not be null.

| Improve this Doc View Source

ToUniversalSortableLongDateTimeString(DateTime, DateTimeFormatInfo)

Converts the DateTime value to a universal sortable long date time string.

Declaration
public static string ToUniversalSortableLongDateTimeString(this DateTime dateTime, DateTimeFormatInfo formatInfo)
Parameters
Type Name Description
System.DateTime dateTime

The DateTime value to convert.

System.Globalization.DateTimeFormatInfo formatInfo

The date time format info.

Returns
Type Description
System.String

The given value converted to a universal sortable long date time string.

Exceptions
Type Condition
System.ArgumentNullException

The format info can not be null.

| Improve this Doc View Source

ToYearMonthString(DateTime)

Converts the DateTime value to a year month string.

Declaration
public static string ToYearMonthString(this DateTime dateTime)
Parameters
Type Name Description
System.DateTime dateTime

The DateTime value to convert.

Returns
Type Description
System.String

The given value converted to a year month string.

| Improve this Doc View Source

ToYearMonthString(DateTime, CultureInfo)

Converts the DateTime value to a year month string.

Declaration
public static string ToYearMonthString(this DateTime dateTime, CultureInfo culture)
Parameters
Type Name Description
System.DateTime dateTime

The DateTime value to convert.

System.Globalization.CultureInfo culture

The culture.

Returns
Type Description
System.String

The given value converted to a year month string.

Exceptions
Type Condition
System.ArgumentNullException

The culture can not be null.

| Improve this Doc View Source

ToYearMonthString(DateTime, DateTimeFormatInfo)

Converts the DateTime value to year month string.

Declaration
public static string ToYearMonthString(this DateTime dateTime, DateTimeFormatInfo formatInfo)
Parameters
Type Name Description
System.DateTime dateTime

The DateTime value to convert.

System.Globalization.DateTimeFormatInfo formatInfo

The date time format info.

Returns
Type Description
System.String

The given value converted to year month string.

Exceptions
Type Condition
System.ArgumentNullException

The format info can not be null.

| Improve this Doc View Source

Yesterday(DateTime)

Subtracts a day to the given date dateTime value.

Declaration
public static DateTime Yesterday(this DateTime dateTime)
Parameters
Type Name Description
System.DateTime dateTime

The date dateTime to decrease.

Returns
Type Description
System.DateTime

Yesterday date at same dateTime.

  • Improve this Doc
  • View Source
Back to top Copyright © 2015-2016 Microsoft
Generated by DocFX