Npgsql Api Docs

NpgsqlInterval Members

NpgsqlInterval overview

Public Static (Shared) Fields

DaysPerMonth Represents the number of days assumed in one month if month justification or unjustifcation is performed. This is set to 30 for consistency with PostgreSQL. Note that this is means that month adjustments cause a year to be taken as 30 × 12 = 360 rather than 356/366 days.
HoursPerDay Represents the number of hours in one day (assuming no daylight savings adjustments). This field is constant.
MaxValue Represents the maximum NpgsqlInterval. This field is read-only.
MinValue Represents the minimum NpgsqlInterval. This field is read-only.
MonthsPerYear Represents the number of months in a year. This field is constant.
TicksPerDay Represents the number of ticks (100ns periods) in one day. This field is constant.
TicksPerHour Represents the number of ticks (100ns periods) in one hour. This field is constant.
TicksPerMicrosecond Represents the number of ticks (100ns periods) in one microsecond. This field is constant.
TicksPerMillsecond Represents the number of ticks (100ns periods) in one millisecond. This field is constant.
TicksPerMinute Represents the number of ticks (100ns periods) in one minute. This field is constant.
TicksPerMonth Represents the number of ticks (100ns periods) in one day, assuming 30 days per month.
TicksPerSecond Represents the number of ticks (100ns periods) in one second. This field is constant.
Zero Represents the zero NpgsqlInterval. This field is read-only.

Public Static (Shared) Methods

Compare Compares two NpgsqlInterval instances.
FromDays Creates an NpgsqlInterval from a number of days.
FromHours Creates an NpgsqlInterval from a number of hours.
FromMicroseconds Creates an NpgsqlInterval from a number of microseconds.
FromMilliseconds Creates an NpgsqlInterval from a number of milliseconds.
FromMinutes Creates an NpgsqlInterval from a number of minutes.
FromMonths Creates an NpgsqlInterval from a number of months.
FromSeconds Creates an NpgsqlInterval from a number of seconds.
FromTicks Creates an NpgsqlInterval from a number of ticks.
Parse Parses a String and returns a NpgsqlInterval instance. Designed to use the formats generally returned by PostgreSQL.
TryParse Attempt to parse a String to produce an NpgsqlInterval.

Public Static (Shared) Operators and Type Conversions

Addition Operator Adds two NpgsqlInterval together.
Equality Operator Returns true if two NpgsqlInterval are exactly the same.
Greater Than Operator Compares two NpgsqlInterval instances to see if the first is greater than the second
Greater Than Or Equal Operator Compares two NpgsqlInterval instances to see if the first is greater than or equivalent the second
Inequality Operator Returns false if two NpgsqlInterval are exactly the same.
Less Than Operator Compares two NpgsqlInterval instances to see if the first is less than the second
Less Than Or Equal Operator Compares two NpgsqlInterval instances to see if the first is less than or equivalent to the second
Subtraction Operator Subtracts one NpgsqlInterval from another.
Unary Negation Operator Negates an NpgsqlInterval instance.
Unary Plus Operator Returns the instance.
Explicit NpgsqlInterval to TimeSpan Conversion Implicit cast of an NpgsqlInterval to a TimeSpan.
Implicit TimeSpan to NpgsqlInterval Conversion Implicit cast of a TimeSpan to an NpgsqlInterval

Public Instance Constructors

NpgsqlInterval Overloaded. Initializes a new instance of the NpgsqlInterval class.

Public Instance Properties

Days Gets the number of days held in the instance. Note that this does not pay attention to a time component with -24 or less hours or 24 or more hours, unless JustifyDays has been called to produce this instance.
Hours Gets the number of whole hours held in the instance. Note that this can be less than -23 or greater than 23 unless JustifyDays has been used to produce this instance.
Microseconds Gets the number of whole microseconds held in the instance. An in the range [-999999, 999999].
Milliseconds Gets the number of whole milliseconds held in the instance. An in the range [-999, 999].
Minutes Gets the number of whole minutes held in the instance. An in the range [-59, 59].
Months Gets the number of months held in the instance. Note that this does not pay attention to a day component with -30 or less days or 30 or more days, unless JustifyMonths has been called to produce this instance.
Seconds Gets the number of whole seconds held in the instance. An in the range [-59, 59].
Ticks The total number of ticks(100ns units) contained. This is the resolution of the NpgsqlInterval type. This ignores the number of days and months held. If you want them included use UnjustifyInterval first. The resolution of the PostgreSQL interval type is by default 1µs = 1,000 ns. It may be smaller as follows:
  1. interval(0) - resolution of 1s (1 second)
  2. interval(1) - resolution of 100ms = 0.1s (100 milliseconds)
  3. interval(2) - resolution of 10ms = 0.01s (10 milliseconds)
  4. interval(3) - resolution of 1ms = 0.001s (1 millisecond)
  5. interval(4) - resolution of 100µs = 0.0001s (100 microseconds)
  6. interval(5) - resolution of 10µs = 0.00001s (10 microseconds)
  7. interval(6) or interval - resolution of 1µs = 0.000001s (1 microsecond)

As such, if the 100-nanosecond resolution is significant to an application, a PostgreSQL interval will not suffice for those purposes.

In more frequent cases though, the resolution of the interval suffices. NpgsqlInterval will always suffice to handle the resolution of any interval value, and upon writing to the database, will be rounded to the resolution used.

The number of ticks in the instance.
Time Returns a TimeSpan representing the time component of the instance. Note that this may have a value beyond the range ±23:59:59.9999999 unless JustifyDays has been called to produce this instance.
TotalDays The total number of days in the instance, assuming 24 hours in each day and 30 days in a month.
TotalHours The total number of hours in the instance, assuming 24 hours in each day and 30 days in a month.
TotalMicroseconds The total number of microseconds in the instance, assuming 24 hours in each day and 30 days in a month.
TotalMilliseconds The total number of milliseconds in the instance, assuming 24 hours in each day and 30 days in a month.
TotalMinutes The total number of minutes in the instance, assuming 24 hours in each day and 30 days in a month.
TotalMonths The total number of months in the instance, assuming 24 hours in each day and 30 days in a month.
TotalSeconds The total number of seconds in the instance, assuming 24 hours in each day and 30 days in a month.
TotalTicks The total number of ticks (100ns units) in the instance, assuming 24 hours in each day and 30 days in a month.

Public Instance Methods

Add Adds another interval to this instance and returns the result.
Canonicalize 
CompareToOverloaded. Compares this instance with another/
Duration This absolute value of this instance. In the case of some, but not all, components being negative, the rules used for justification are used to determine if the instance is positive or negative.
EqualsOverloaded. Returns true if another NpgsqlInterval is exactly the same as this instance.
GetHashCode A hash code suitable for uses with hashing algorithms.
GetType (inherited from Object) 
JustifyDays Equivalent to PostgreSQL's justify_days function.
JustifyInterval Equivalent to PostgreSQL's justify_interval function.
JustifyMonths Equivalent to PostgreSQL's justify_months function.
Negate Returns an NpgsqlInterval whose value is the negated value of this instance.
Subtract Subtracts another interval from this instance and returns the result.
ToString Create a String representation of the NpgsqlInterval instance. The format returned is of the form: [M mon[s]] [d day[s]] [HH:mm:ss[.f[f[f[f[f[f[f[f[f]]]]]]]]]] A zero NpgsqlInterval is represented as 00:00:00 Ticks are 100ns, Postgress resolution is only to 1µs at most. Hence we lose 1 or more decimal precision in storing values in the database. Despite this, this method will output that extra digit of precision. It's forward-compatible with any future increases in resolution up to 100ns, and also makes this ToString() more applicable to any other use-case.
UnjustifyDays Opposite to PostgreSQL's justify_days function.
UnjustifyInterval Opposite to PostgreSQL's justify_interval function.
UnjustifyMonths Opposite to PostgreSQL's justify_months function.

See Also

NpgsqlInterval Class | NpgsqlTypes Namespace | Ticks | JustifyDays | JustifyMonths | Canonicalize