Npgsql Api Docs |

# NpgsqlInterval Structure

Represents the PostgreSQL interval datatype. PostgreSQL differs from .NET in how it's interval type doesn't assume 24 hours in a day (to deal with 23- and 25-hour days caused by daylight savings adjustments) and has a concept of months that doesn't exist in .NET's TimeSpan class. (Neither datatype has any concessions for leap-seconds).

For most uses just casting to and from TimeSpan will work correctly — in particular, the results of subtracting one DateTime or the PostgreSQL date, time and timestamp types from another should be the same whether you do so in .NET or PostgreSQL — but if the handling of days and months in PostgreSQL is important to your application then you should use this class instead of TimeSpan.

If you don't know whether these differences are important to your application, they probably arent! Just use TimeSpan and do not use this class directly ?

To avoid forcing unnecessary provider-specific concerns on users who need not be concerned with them a call to GetValue on a field containing an NpgsqlInterval value will return a TimeSpan rather than an NpgsqlInterval. If you need the extra functionality of NpgsqlInterval then use GetInterval.

For a list of all members of this type, see NpgsqlInterval Members.

System.Object
System.ValueType
NpgsqlTypes.NpgsqlInterval

[Visual Basic]
Public Structure NpgsqlInterval
Implements IEquatable`1([NpgsqlTypes.NpgsqlInterval, Npgsql, Version=2.0.3.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7)), IComparable`1([NpgsqlTypes.NpgsqlInterval, Npgsql, Version=2.0.3.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7)), IComparer`1([NpgsqlTypes.NpgsqlInterval, Npgsql, Version=2.0.3.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7)), IComparable, IComparer
[C#]
public struct NpgsqlInterval : 0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7]], 0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7]], 0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7]], IComparable, IComparer

#### Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

#### Requirements

Namespace: NpgsqlTypes

Assembly: Npgsql (in Npgsql.dll)

#### See Also

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