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
System.IComparable
System.Collections.IComparer
Inherited Members
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetType()
Assembly: Npgsql.dll
Syntax
[Serializable]
public struct NpgsqlDateTime : IEquatable<NpgsqlDateTime>, IComparable<NpgsqlDateTime>, IComparable, IComparer<NpgsqlDateTime>, IComparer
Constructors
NpgsqlDateTime(NpgsqlDate)
Declaration
public NpgsqlDateTime(NpgsqlDate date)
Parameters
NpgsqlDateTime(NpgsqlDate, TimeSpan, DateTimeKind)
Declaration
public NpgsqlDateTime(NpgsqlDate date, TimeSpan time, DateTimeKind kind = DateTimeKind.Unspecified)
Parameters
Type |
Name |
Description |
NpgsqlDate |
date |
|
System.TimeSpan |
time |
|
System.DateTimeKind |
kind |
|
NpgsqlDateTime(DateTime)
Declaration
public NpgsqlDateTime(DateTime dateTime)
Parameters
Type |
Name |
Description |
System.DateTime |
dateTime |
|
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 |
System.Int32 |
year |
|
System.Int32 |
month |
|
System.Int32 |
day |
|
System.Int32 |
hours |
|
System.Int32 |
minutes |
|
System.Int32 |
seconds |
|
System.DateTimeKind |
kind |
|
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 |
System.Int32 |
year |
|
System.Int32 |
month |
|
System.Int32 |
day |
|
System.Int32 |
hours |
|
System.Int32 |
minutes |
|
System.Int32 |
seconds |
|
System.Int32 |
milliseconds |
|
System.DateTimeKind |
kind |
|
NpgsqlDateTime(Int64)
Declaration
public NpgsqlDateTime(long ticks)
Parameters
Type |
Name |
Description |
System.Int64 |
ticks |
|
NpgsqlDateTime(Int64, DateTimeKind)
Declaration
public NpgsqlDateTime(long ticks, DateTimeKind kind)
Parameters
Type |
Name |
Description |
System.Int64 |
ticks |
|
System.DateTimeKind |
kind |
|
Fields
Epoch
Declaration
public static readonly NpgsqlDateTime Epoch
Field Value
Era
Declaration
public static readonly NpgsqlDateTime Era
Field Value
Infinity
Declaration
public static readonly NpgsqlDateTime Infinity
Field Value
NegativeInfinity
Declaration
public static readonly NpgsqlDateTime NegativeInfinity
Field Value
Properties
Date
Declaration
public NpgsqlDate Date { get; }
Property Value
Day
Declaration
Property Value
Type |
Description |
System.Int32 |
|
DayOfWeek
Declaration
public DayOfWeek DayOfWeek { get; }
Property Value
Type |
Description |
System.DayOfWeek |
|
DayOfYear
Declaration
public int DayOfYear { get; }
Property Value
Type |
Description |
System.Int32 |
|
Hour
Declaration
Property Value
Type |
Description |
System.Int32 |
|
IsFinite
Declaration
public bool IsFinite { get; }
Property Value
Type |
Description |
System.Boolean |
|
IsInfinity
Declaration
public bool IsInfinity { get; }
Property Value
Type |
Description |
System.Boolean |
|
IsLeapYear
Declaration
public bool IsLeapYear { get; }
Property Value
Type |
Description |
System.Boolean |
|
IsNegativeInfinity
Declaration
public bool IsNegativeInfinity { get; }
Property Value
Type |
Description |
System.Boolean |
|
Kind
Declaration
public DateTimeKind Kind { get; }
Property Value
Type |
Description |
System.DateTimeKind |
|
Millisecond
Declaration
public int Millisecond { get; }
Property Value
Type |
Description |
System.Int32 |
|
Minute
Declaration
public int Minute { get; }
Property Value
Type |
Description |
System.Int32 |
|
Month
Declaration
public int Month { get; }
Property Value
Type |
Description |
System.Int32 |
|
Now
Declaration
public static NpgsqlDateTime Now { get; }
Property Value
Second
Declaration
public int Second { get; }
Property Value
Type |
Description |
System.Int32 |
|
Ticks
Declaration
public long Ticks { get; }
Property Value
Type |
Description |
System.Int64 |
|
Time
Declaration
public TimeSpan Time { get; }
Property Value
Type |
Description |
System.TimeSpan |
|
Year
Declaration
Property Value
Type |
Description |
System.Int32 |
|
Methods
Add(NpgsqlTimeSpan)
Returns a new NpgsqlDateTime that adds the value of the specified TimeSpan to the value of this instance.
Declaration
public NpgsqlDateTime Add(NpgsqlTimeSpan value)
Parameters
Type |
Name |
Description |
NpgsqlTimeSpan |
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.
|
Add(TimeSpan)
Declaration
public NpgsqlDateTime Add(TimeSpan value)
Parameters
Type |
Name |
Description |
System.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.
|
AddDays(Double)
Returns a new NpgsqlDateTime that adds the specified number of days to the value of this instance.
Declaration
public NpgsqlDateTime AddDays(double value)
Parameters
Type |
Name |
Description |
System.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.
|
AddHours(Double)
Returns a new NpgsqlDateTime that adds the specified number of hours to the value of this instance.
Declaration
public NpgsqlDateTime AddHours(double value)
Parameters
Type |
Name |
Description |
System.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.
|
AddMilliseconds(Double)
Returns a new NpgsqlDateTime that adds the specified number of milliseconds to the value of this instance.
Declaration
public NpgsqlDateTime AddMilliseconds(double value)
Parameters
Type |
Name |
Description |
System.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.
|
AddMinutes(Double)
Returns a new NpgsqlDateTime that adds the specified number of minutes to the value of this instance.
Declaration
public NpgsqlDateTime AddMinutes(double value)
Parameters
Type |
Name |
Description |
System.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.
|
AddMonths(Int32)
Returns a new NpgsqlDateTime that adds the specified number of months to the value of this instance.
Declaration
public NpgsqlDateTime AddMonths(int value)
Parameters
Type |
Name |
Description |
System.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.
|
AddSeconds(Double)
Returns a new NpgsqlDateTime that adds the specified number of minutes to the value of this instance.
Declaration
public NpgsqlDateTime AddSeconds(double value)
Parameters
Type |
Name |
Description |
System.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.
|
AddTicks(Int64)
Returns a new NpgsqlDateTime that adds the specified number of ticks to the value of this instance.
Declaration
public NpgsqlDateTime AddTicks(long value)
Parameters
Type |
Name |
Description |
System.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.
|
AddYears(Int32)
Returns a new NpgsqlDateTime that adds the specified number of years to the value of this instance.
Declaration
public NpgsqlDateTime AddYears(int value)
Parameters
Type |
Name |
Description |
System.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.
|
Compare(NpgsqlDateTime, NpgsqlDateTime)
Declaration
public int Compare(NpgsqlDateTime x, NpgsqlDateTime y)
Parameters
Returns
Type |
Description |
System.Int32 |
|
Compare(Object, Object)
Declaration
public int Compare(object x, object y)
Parameters
Type |
Name |
Description |
System.Object |
x |
|
System.Object |
y |
|
Returns
Type |
Description |
System.Int32 |
|
CompareTo(NpgsqlDateTime)
Declaration
public int CompareTo(NpgsqlDateTime other)
Parameters
Returns
Type |
Description |
System.Int32 |
|
CompareTo(Object)
Declaration
public int CompareTo(object o)
Parameters
Type |
Name |
Description |
System.Object |
o |
|
Returns
Type |
Description |
System.Int32 |
|
Equals(NpgsqlDateTime)
Declaration
public bool Equals(NpgsqlDateTime other)
Parameters
Returns
Type |
Description |
System.Boolean |
|
Equals(Object)
Declaration
public override bool Equals(object obj)
Parameters
Type |
Name |
Description |
System.Object |
obj |
|
Returns
Type |
Description |
System.Boolean |
|
Overrides
System.ValueType.Equals(System.Object)
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Type |
Description |
System.Int32 |
|
Overrides
System.ValueType.GetHashCode()
Normalize()
Declaration
public NpgsqlDateTime Normalize()
Returns
Parse(String)
Declaration
public static NpgsqlDateTime Parse(string str)
Parameters
Type |
Name |
Description |
System.String |
str |
|
Returns
Subtract(NpgsqlDateTime)
Declaration
public NpgsqlTimeSpan Subtract(NpgsqlDateTime timestamp)
Parameters
Returns
Subtract(NpgsqlTimeSpan)
Declaration
public NpgsqlDateTime Subtract(NpgsqlTimeSpan interval)
Parameters
Returns
ToDateTime()
Declaration
public DateTime ToDateTime()
Returns
Type |
Description |
System.DateTime |
An equivalent System.DateTime.
|
ToLocalTime()
Converts the value of the current NpgsqlDateTime object to local time.
Declaration
public NpgsqlDateTime ToLocalTime()
Returns
ToNpgsqlDateTime(DateTime)
Declaration
public static NpgsqlDateTime ToNpgsqlDateTime(DateTime dateTime)
Parameters
Type |
Name |
Description |
System.DateTime |
dateTime |
|
Returns
ToString()
Declaration
public override string ToString()
Returns
Type |
Description |
System.String |
|
Overrides
System.ValueType.ToString()
ToUniversalTime()
Converts the value of the current NpgsqlDateTime object to Coordinated Universal Time (UTC).
Declaration
public NpgsqlDateTime ToUniversalTime()
Returns
Operators
Addition(NpgsqlDateTime, NpgsqlTimeSpan)
Declaration
public static NpgsqlDateTime operator +(NpgsqlDateTime timestamp, NpgsqlTimeSpan interval)
Parameters
Returns
Addition(NpgsqlTimeSpan, NpgsqlDateTime)
Declaration
public static NpgsqlDateTime operator +(NpgsqlTimeSpan interval, NpgsqlDateTime timestamp)
Parameters
Returns
Equality(NpgsqlDateTime, NpgsqlDateTime)
Declaration
public static bool operator ==(NpgsqlDateTime x, NpgsqlDateTime y)
Parameters
Returns
Type |
Description |
System.Boolean |
|
Explicit(NpgsqlDateTime to DateTime)
Declaration
public static explicit operator DateTime(NpgsqlDateTime npgsqlDateTime)
Parameters
Returns
Type |
Description |
System.DateTime |
An equivalent System.DateTime.
|
GreaterThan(NpgsqlDateTime, NpgsqlDateTime)
Declaration
public static bool operator>(NpgsqlDateTime x, NpgsqlDateTime y)
Parameters
Returns
Type |
Description |
System.Boolean |
|
GreaterThanOrEqual(NpgsqlDateTime, NpgsqlDateTime)
Declaration
public static bool operator >=(NpgsqlDateTime x, NpgsqlDateTime y)
Parameters
Returns
Type |
Description |
System.Boolean |
|
Implicit(DateTime to NpgsqlDateTime)
Declaration
public static implicit operator NpgsqlDateTime(DateTime dateTime)
Parameters
Type |
Name |
Description |
System.DateTime |
dateTime |
A System.DateTime
|
Returns
Inequality(NpgsqlDateTime, NpgsqlDateTime)
Declaration
public static bool operator !=(NpgsqlDateTime x, NpgsqlDateTime y)
Parameters
Returns
Type |
Description |
System.Boolean |
|
LessThan(NpgsqlDateTime, NpgsqlDateTime)
Declaration
public static bool operator <(NpgsqlDateTime x, NpgsqlDateTime y)
Parameters
Returns
Type |
Description |
System.Boolean |
|
LessThanOrEqual(NpgsqlDateTime, NpgsqlDateTime)
Declaration
public static bool operator <=(NpgsqlDateTime x, NpgsqlDateTime y)
Parameters
Returns
Type |
Description |
System.Boolean |
|
Subtraction(NpgsqlDateTime, NpgsqlDateTime)
Declaration
public static NpgsqlTimeSpan operator -(NpgsqlDateTime x, NpgsqlDateTime y)
Parameters
Returns
Subtraction(NpgsqlDateTime, NpgsqlTimeSpan)
Declaration
public static NpgsqlDateTime operator -(NpgsqlDateTime timestamp, NpgsqlTimeSpan interval)
Parameters
Returns
Implements
System.IEquatable<T>
System.IComparable<T>
System.IComparable
System.Collections.Generic.IComparer<T>
System.Collections.IComparer