Search Results for

    Show / Hide Table of Contents

    Struct NpgsqlDateTime

    A struct similar to .NET DateTime but capable of storing PostgreSQL's timestamp and timestamptz types. DateTime is capable of storing values from year 1 to 9999 at 100-nanosecond precision, while PostgreSQL's timestamps store values from 4713BC to 5874897AD with 1-microsecond precision.

    Implements
    IEquatable<NpgsqlDateTime>
    IComparable<NpgsqlDateTime>
    IComparable
    IComparer<NpgsqlDateTime>
    IComparer
    Inherited Members
    Object.Equals(Object, Object)
    Object.GetType()
    Object.ReferenceEquals(Object, Object)
    Namespace: NpgsqlTypes
    Assembly: Npgsql.dll
    Syntax
    [Serializable]
    public readonly struct NpgsqlDateTime : IEquatable<NpgsqlDateTime>, IComparable<NpgsqlDateTime>, IComparable, IComparer<NpgsqlDateTime>, IComparer

    Constructors

    | Improve this Doc

    NpgsqlDateTime(NpgsqlDate)

    Declaration
    public NpgsqlDateTime(NpgsqlDate date)
    Parameters
    Type Name Description
    NpgsqlDate date
    | Improve this Doc

    NpgsqlDateTime(NpgsqlDate, TimeSpan, DateTimeKind)

    Declaration
    public NpgsqlDateTime(NpgsqlDate date, TimeSpan time, DateTimeKind kind = DateTimeKind.Unspecified)
    Parameters
    Type Name Description
    NpgsqlDate date
    TimeSpan time
    DateTimeKind kind
    | Improve this Doc

    NpgsqlDateTime(DateTime)

    Declaration
    public NpgsqlDateTime(DateTime dateTime)
    Parameters
    Type Name Description
    DateTime dateTime
    | Improve this Doc

    NpgsqlDateTime(Int32, Int32, Int32, Int32, Int32, Int32, DateTimeKind)

    Declaration
    public NpgsqlDateTime(int year, int month, int day, int hours, int minutes, int seconds, DateTimeKind kind = DateTimeKind.Unspecified)
    Parameters
    Type Name Description
    Int32 year
    Int32 month
    Int32 day
    Int32 hours
    Int32 minutes
    Int32 seconds
    DateTimeKind kind
    | Improve this Doc

    NpgsqlDateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32, DateTimeKind)

    Declaration
    public NpgsqlDateTime(int year, int month, int day, int hours, int minutes, int seconds, int milliseconds, DateTimeKind kind = DateTimeKind.Unspecified)
    Parameters
    Type Name Description
    Int32 year
    Int32 month
    Int32 day
    Int32 hours
    Int32 minutes
    Int32 seconds
    Int32 milliseconds
    DateTimeKind kind
    | Improve this Doc

    NpgsqlDateTime(Int64)

    Declaration
    public NpgsqlDateTime(long ticks)
    Parameters
    Type Name Description
    Int64 ticks
    | Improve this Doc

    NpgsqlDateTime(Int64, DateTimeKind)

    Declaration
    public NpgsqlDateTime(long ticks, DateTimeKind kind)
    Parameters
    Type Name Description
    Int64 ticks
    DateTimeKind kind

    Fields

    | Improve this Doc

    Epoch

    Declaration
    public static readonly NpgsqlDateTime Epoch
    Field Value
    Type Description
    NpgsqlDateTime
    | Improve this Doc

    Era

    Declaration
    public static readonly NpgsqlDateTime Era
    Field Value
    Type Description
    NpgsqlDateTime
    | Improve this Doc

    Infinity

    Declaration
    public static readonly NpgsqlDateTime Infinity
    Field Value
    Type Description
    NpgsqlDateTime
    | Improve this Doc

    NegativeInfinity

    Declaration
    public static readonly NpgsqlDateTime NegativeInfinity
    Field Value
    Type Description
    NpgsqlDateTime

    Properties

    | Improve this Doc

    Date

    Declaration
    public readonly NpgsqlDate Date { get; }
    Property Value
    Type Description
    NpgsqlDate
    | Improve this Doc

    Day

    Declaration
    public readonly int Day { get; }
    Property Value
    Type Description
    Int32
    | Improve this Doc

    DayOfWeek

    Declaration
    public readonly DayOfWeek DayOfWeek { get; }
    Property Value
    Type Description
    DayOfWeek
    | Improve this Doc

    DayOfYear

    Declaration
    public readonly int DayOfYear { get; }
    Property Value
    Type Description
    Int32
    | Improve this Doc

    Hour

    Declaration
    public readonly int Hour { get; }
    Property Value
    Type Description
    Int32
    | Improve this Doc

    IsFinite

    Declaration
    public readonly bool IsFinite { get; }
    Property Value
    Type Description
    Boolean
    | Improve this Doc

    IsInfinity

    Declaration
    public readonly bool IsInfinity { get; }
    Property Value
    Type Description
    Boolean
    | Improve this Doc

    IsLeapYear

    Declaration
    public readonly bool IsLeapYear { get; }
    Property Value
    Type Description
    Boolean
    | Improve this Doc

    IsNegativeInfinity

    Declaration
    public readonly bool IsNegativeInfinity { get; }
    Property Value
    Type Description
    Boolean
    | Improve this Doc

    Kind

    Declaration
    public readonly DateTimeKind Kind { get; }
    Property Value
    Type Description
    DateTimeKind
    | Improve this Doc

    Millisecond

    Declaration
    public readonly int Millisecond { get; }
    Property Value
    Type Description
    Int32
    | Improve this Doc

    Minute

    Declaration
    public readonly int Minute { get; }
    Property Value
    Type Description
    Int32
    | Improve this Doc

    Month

    Declaration
    public readonly int Month { get; }
    Property Value
    Type Description
    Int32
    | Improve this Doc

    Now

    Declaration
    public static readonly NpgsqlDateTime Now { get; }
    Property Value
    Type Description
    NpgsqlDateTime
    | Improve this Doc

    Second

    Declaration
    public readonly int Second { get; }
    Property Value
    Type Description
    Int32
    | Improve this Doc

    Ticks

    Declaration
    public readonly long Ticks { get; }
    Property Value
    Type Description
    Int64
    | Improve this Doc

    Time

    Declaration
    public readonly TimeSpan Time { get; }
    Property Value
    Type Description
    TimeSpan
    | Improve this Doc

    Year

    Declaration
    public readonly int Year { get; }
    Property Value
    Type Description
    Int32

    Methods

    | Improve this Doc

    Add(NpgsqlTimeSpan)

    Returns a new NpgsqlDateTime that adds the value of the specified NpgsqlTimeSpan to the value of this instance.

    Declaration
    public readonly NpgsqlDateTime Add(NpgsqlTimeSpan value)
    Parameters
    Type Name Description
    NpgsqlTimeSpan value

    An NpgsqlTimeSpan interval.

    Returns
    Type Description
    NpgsqlDateTime

    An object whose value is the sum of the date and time represented by this instance and the time interval represented by value.

    | Improve this Doc

    Add(TimeSpan)

    Returns a new NpgsqlDateTime that adds the value of the specified TimeSpan to the value of this instance.

    Declaration
    public readonly NpgsqlDateTime Add(TimeSpan value)
    Parameters
    Type Name Description
    TimeSpan value

    A positive or negative time interval.

    Returns
    Type Description
    NpgsqlDateTime

    An object whose value is the sum of the date and time represented by this instance and the time interval represented by value.

    | Improve this Doc

    AddDays(Double)

    Returns a new NpgsqlDateTime that adds the specified number of days to the value of this instance.

    Declaration
    public readonly NpgsqlDateTime AddDays(double value)
    Parameters
    Type Name Description
    Double value

    A number of whole and fractional days. The value parameter can be negative or positive.

    Returns
    Type Description
    NpgsqlDateTime

    An object whose value is the sum of the date and time represented by this instance and the number of days represented by value.

    | Improve this Doc

    AddHours(Double)

    Returns a new NpgsqlDateTime that adds the specified number of hours to the value of this instance.

    Declaration
    public readonly NpgsqlDateTime AddHours(double value)
    Parameters
    Type Name Description
    Double value

    A number of whole and fractional hours. The value parameter can be negative or positive.

    Returns
    Type Description
    NpgsqlDateTime

    An object whose value is the sum of the date and time represented by this instance and the number of hours represented by value.

    | Improve this Doc

    AddMilliseconds(Double)

    Returns a new NpgsqlDateTime that adds the specified number of milliseconds to the value of this instance.

    Declaration
    public readonly NpgsqlDateTime AddMilliseconds(double value)
    Parameters
    Type Name Description
    Double value

    A number of whole and fractional milliseconds. The value parameter can be negative or positive. Note that this value is rounded to the nearest integer.

    Returns
    Type Description
    NpgsqlDateTime

    An object whose value is the sum of the date and time represented by this instance and the number of milliseconds represented by value.

    | Improve this Doc

    AddMinutes(Double)

    Returns a new NpgsqlDateTime that adds the specified number of minutes to the value of this instance.

    Declaration
    public readonly NpgsqlDateTime AddMinutes(double value)
    Parameters
    Type Name Description
    Double value

    A number of whole and fractional minutes. The value parameter can be negative or positive.

    Returns
    Type Description
    NpgsqlDateTime

    An object whose value is the sum of the date and time represented by this instance and the number of minutes represented by value.

    | Improve this Doc

    AddMonths(Int32)

    Returns a new NpgsqlDateTime that adds the specified number of months to the value of this instance.

    Declaration
    public readonly NpgsqlDateTime AddMonths(int value)
    Parameters
    Type Name Description
    Int32 value

    A number of months. The months parameter can be negative or positive.

    Returns
    Type Description
    NpgsqlDateTime

    An object whose value is the sum of the date and time represented by this instance and months.

    | Improve this Doc

    AddSeconds(Double)

    Returns a new NpgsqlDateTime that adds the specified number of minutes to the value of this instance.

    Declaration
    public readonly NpgsqlDateTime AddSeconds(double value)
    Parameters
    Type Name Description
    Double value

    A number of whole and fractional minutes. The value parameter can be negative or positive.

    Returns
    Type Description
    NpgsqlDateTime

    An object whose value is the sum of the date and time represented by this instance and the number of minutes represented by value.

    | Improve this Doc

    AddTicks(Int64)

    Returns a new NpgsqlDateTime that adds the specified number of ticks to the value of this instance.

    Declaration
    public readonly NpgsqlDateTime AddTicks(long value)
    Parameters
    Type Name Description
    Int64 value

    A number of 100-nanosecond ticks. The value parameter can be positive or negative.

    Returns
    Type Description
    NpgsqlDateTime

    An object whose value is the sum of the date and time represented by this instance and the time represented by value.

    | Improve this Doc

    AddYears(Int32)

    Returns a new NpgsqlDateTime that adds the specified number of years to the value of this instance.

    Declaration
    public readonly NpgsqlDateTime AddYears(int value)
    Parameters
    Type Name Description
    Int32 value

    A number of years. The value parameter can be negative or positive.

    Returns
    Type Description
    NpgsqlDateTime

    An object whose value is the sum of the date and time represented by this instance and the number of years represented by value.

    | Improve this Doc

    Compare(NpgsqlDateTime, NpgsqlDateTime)

    Declaration
    public readonly int Compare(NpgsqlDateTime x, NpgsqlDateTime y)
    Parameters
    Type Name Description
    NpgsqlDateTime x
    NpgsqlDateTime y
    Returns
    Type Description
    Int32
    | Improve this Doc

    Compare(Object, Object)

    Declaration
    public readonly int Compare(object x, object y)
    Parameters
    Type Name Description
    Object x
    Object y
    Returns
    Type Description
    Int32
    | Improve this Doc

    CompareTo(NpgsqlDateTime)

    Declaration
    public readonly int CompareTo(NpgsqlDateTime other)
    Parameters
    Type Name Description
    NpgsqlDateTime other
    Returns
    Type Description
    Int32
    | Improve this Doc

    CompareTo(Object)

    Declaration
    public readonly int CompareTo(object o)
    Parameters
    Type Name Description
    Object o
    Returns
    Type Description
    Int32
    | Improve this Doc

    Equals(NpgsqlDateTime)

    Declaration
    public readonly bool Equals(NpgsqlDateTime other)
    Parameters
    Type Name Description
    NpgsqlDateTime other
    Returns
    Type Description
    Boolean
    | Improve this Doc

    Equals(Object)

    Declaration
    public override readonly bool Equals(object obj)
    Parameters
    Type Name Description
    Object obj
    Returns
    Type Description
    Boolean
    Overrides
    ValueType.Equals(Object)
    | Improve this Doc

    GetHashCode()

    Declaration
    public override readonly int GetHashCode()
    Returns
    Type Description
    Int32
    Overrides
    ValueType.GetHashCode()
    | Improve this Doc

    Normalize()

    Declaration
    public readonly NpgsqlDateTime Normalize()
    Returns
    Type Description
    NpgsqlDateTime
    | Improve this Doc

    Parse(String)

    Declaration
    public static NpgsqlDateTime Parse(string str)
    Parameters
    Type Name Description
    String str
    Returns
    Type Description
    NpgsqlDateTime
    | Improve this Doc

    Subtract(NpgsqlDateTime)

    Declaration
    public readonly NpgsqlTimeSpan Subtract(NpgsqlDateTime timestamp)
    Parameters
    Type Name Description
    NpgsqlDateTime timestamp
    Returns
    Type Description
    NpgsqlTimeSpan
    | Improve this Doc

    Subtract(NpgsqlTimeSpan)

    Declaration
    public readonly NpgsqlDateTime Subtract(NpgsqlTimeSpan interval)
    Parameters
    Type Name Description
    NpgsqlTimeSpan interval
    Returns
    Type Description
    NpgsqlDateTime
    | Improve this Doc

    ToDateTime()

    Cast of an NpgsqlDateTime to a DateTime.

    Declaration
    public readonly DateTime ToDateTime()
    Returns
    Type Description
    DateTime

    An equivalent DateTime.

    | Improve this Doc

    ToLocalTime()

    Converts the value of the current NpgsqlDateTime object to local time.

    Declaration
    public readonly NpgsqlDateTime ToLocalTime()
    Returns
    Type Description
    NpgsqlDateTime
    Remarks

    See the MSDN documentation for DateTime.ToLocalTime(). Note: this method only takes into account the time zone's base offset, and does not respect daylight savings. See https://github.com/npgsql/npgsql/pull/684 for more details.

    | Improve this Doc

    ToNpgsqlDateTime(DateTime)

    Declaration
    public static NpgsqlDateTime ToNpgsqlDateTime(DateTime dateTime)
    Parameters
    Type Name Description
    DateTime dateTime
    Returns
    Type Description
    NpgsqlDateTime
    | Improve this Doc

    ToString()

    Declaration
    public override readonly string ToString()
    Returns
    Type Description
    String
    Overrides
    ValueType.ToString()
    | Improve this Doc

    ToUniversalTime()

    Converts the value of the current NpgsqlDateTime object to Coordinated Universal Time (UTC).

    Declaration
    public readonly NpgsqlDateTime ToUniversalTime()
    Returns
    Type Description
    NpgsqlDateTime
    Remarks

    See the MSDN documentation for DateTime.ToUniversalTime(). Note: this method only takes into account the time zone's base offset, and does not respect daylight savings. See https://github.com/npgsql/npgsql/pull/684 for more details.

    Operators

    | Improve this Doc

    Addition(NpgsqlDateTime, NpgsqlTimeSpan)

    Declaration
    public static NpgsqlDateTime operator +(NpgsqlDateTime timestamp, NpgsqlTimeSpan interval)
    Parameters
    Type Name Description
    NpgsqlDateTime timestamp
    NpgsqlTimeSpan interval
    Returns
    Type Description
    NpgsqlDateTime
    | Improve this Doc

    Addition(NpgsqlTimeSpan, NpgsqlDateTime)

    Declaration
    public static NpgsqlDateTime operator +(NpgsqlTimeSpan interval, NpgsqlDateTime timestamp)
    Parameters
    Type Name Description
    NpgsqlTimeSpan interval
    NpgsqlDateTime timestamp
    Returns
    Type Description
    NpgsqlDateTime
    | Improve this Doc

    Equality(NpgsqlDateTime, NpgsqlDateTime)

    Declaration
    public static bool operator ==(NpgsqlDateTime x, NpgsqlDateTime y)
    Parameters
    Type Name Description
    NpgsqlDateTime x
    NpgsqlDateTime y
    Returns
    Type Description
    Boolean
    | Improve this Doc

    Explicit(NpgsqlDateTime to DateTime)

    Explicit cast of an NpgsqlDateTime to a DateTime.

    Declaration
    public static explicit operator DateTime(NpgsqlDateTime npgsqlDateTime)
    Parameters
    Type Name Description
    NpgsqlDateTime npgsqlDateTime

    An NpgsqlDateTime.

    Returns
    Type Description
    DateTime

    An equivalent DateTime.

    | Improve this Doc

    GreaterThan(NpgsqlDateTime, NpgsqlDateTime)

    Declaration
    public static bool operator>(NpgsqlDateTime x, NpgsqlDateTime y)
    Parameters
    Type Name Description
    NpgsqlDateTime x
    NpgsqlDateTime y
    Returns
    Type Description
    Boolean
    | Improve this Doc

    GreaterThanOrEqual(NpgsqlDateTime, NpgsqlDateTime)

    Declaration
    public static bool operator >=(NpgsqlDateTime x, NpgsqlDateTime y)
    Parameters
    Type Name Description
    NpgsqlDateTime x
    NpgsqlDateTime y
    Returns
    Type Description
    Boolean
    | Improve this Doc

    Implicit(DateTime to NpgsqlDateTime)

    Implicit cast of a DateTime to an NpgsqlDateTime

    Declaration
    public static implicit operator NpgsqlDateTime(DateTime dateTime)
    Parameters
    Type Name Description
    DateTime dateTime

    A DateTime

    Returns
    Type Description
    NpgsqlDateTime

    An equivalent NpgsqlDateTime.

    | Improve this Doc

    Inequality(NpgsqlDateTime, NpgsqlDateTime)

    Declaration
    public static bool operator !=(NpgsqlDateTime x, NpgsqlDateTime y)
    Parameters
    Type Name Description
    NpgsqlDateTime x
    NpgsqlDateTime y
    Returns
    Type Description
    Boolean
    | Improve this Doc

    LessThan(NpgsqlDateTime, NpgsqlDateTime)

    Declaration
    public static bool operator <(NpgsqlDateTime x, NpgsqlDateTime y)
    Parameters
    Type Name Description
    NpgsqlDateTime x
    NpgsqlDateTime y
    Returns
    Type Description
    Boolean
    | Improve this Doc

    LessThanOrEqual(NpgsqlDateTime, NpgsqlDateTime)

    Declaration
    public static bool operator <=(NpgsqlDateTime x, NpgsqlDateTime y)
    Parameters
    Type Name Description
    NpgsqlDateTime x
    NpgsqlDateTime y
    Returns
    Type Description
    Boolean
    | Improve this Doc

    Subtraction(NpgsqlDateTime, NpgsqlDateTime)

    Declaration
    public static NpgsqlTimeSpan operator -(NpgsqlDateTime x, NpgsqlDateTime y)
    Parameters
    Type Name Description
    NpgsqlDateTime x
    NpgsqlDateTime y
    Returns
    Type Description
    NpgsqlTimeSpan
    | Improve this Doc

    Subtraction(NpgsqlDateTime, NpgsqlTimeSpan)

    Declaration
    public static NpgsqlDateTime operator -(NpgsqlDateTime timestamp, NpgsqlTimeSpan interval)
    Parameters
    Type Name Description
    NpgsqlDateTime timestamp
    NpgsqlTimeSpan interval
    Returns
    Type Description
    NpgsqlDateTime

    Implements

    System.IEquatable<T>
    System.IComparable<T>
    System.IComparable
    System.Collections.Generic.IComparer<T>
    System.Collections.IComparer
    • Improve this Doc
    In This Article
    Back to top © Copyright 2021 The Npgsql Development Team