DateTimeExtensions..::..DateDiff Method

DateDiff in SQL style. Datepart implemented: "year" (abbr. "yy", "yyyy"), "quarter" (abbr. "qq", "q"), "month" (abbr. "mm", "m"), "day" (abbr. "dd", "d"), "week" (abbr. "wk", "ww"), "hour" (abbr. "hh"), "minute" (abbr. "mi", "n"), "second" (abbr. "ss", "s"), "millisecond" (abbr. "ms"). Gets the total days from 01/01/2000. DateTime dt = new DateTime(2000, 01, 01); Int64 days = dt.DateDiff("day", DateTime.Now); Gets the total hours from 01/01/2000. Int64 hours = dt.DateDiff("hour", DateTime.Now);

Namespace:  Core
Assembly:  Core (in Core.dll)

Syntax


public static long DateDiff(
	DateTime StartDate,
	string DatePart,
	DateTime EndDate
)

Parameters

StartDate
Type: DateTime
The start date.
DatePart
Type: String
The date part.
EndDate
Type: DateTime
The end date.

Return Value

returns Int64

Exceptions


ExceptionCondition
ExceptionDatePart is unknown