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.
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
|
Improve this Doc
NpgsqlDateTime(NpgsqlDate, TimeSpan, DateTimeKind)
Declaration
public NpgsqlDateTime(NpgsqlDate date, TimeSpan time, DateTimeKind kind = DateTimeKind.Unspecified)
Parameters
|
Improve this Doc
NpgsqlDateTime(DateTime)
Declaration
public NpgsqlDateTime(DateTime dateTime)
Parameters
|
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
|
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
|
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
Fields
|
Improve this Doc
Epoch
Declaration
public static readonly NpgsqlDateTime Epoch
Field Value
|
Improve this Doc
Era
Declaration
public static readonly NpgsqlDateTime Era
Field Value
|
Improve this Doc
Infinity
Declaration
public static readonly NpgsqlDateTime Infinity
Field Value
|
Improve this Doc
NegativeInfinity
Declaration
public static readonly NpgsqlDateTime NegativeInfinity
Field Value
Properties
|
Improve this Doc
Date
Declaration
public readonly NpgsqlDate Date { get; }
Property Value
|
Improve this Doc
Day
Declaration
public readonly int Day { get; }
Property Value
|
Improve this Doc
DayOfWeek
Declaration
public readonly DayOfWeek DayOfWeek { get; }
Property Value
|
Improve this Doc
DayOfYear
Declaration
public readonly int DayOfYear { get; }
Property Value
|
Improve this Doc
Hour
Declaration
public readonly int Hour { get; }
Property Value
|
Improve this Doc
IsFinite
Declaration
public readonly bool IsFinite { get; }
Property Value
|
Improve this Doc
IsInfinity
Declaration
public readonly bool IsInfinity { get; }
Property Value
|
Improve this Doc
IsLeapYear
Declaration
public readonly bool IsLeapYear { get; }
Property Value
|
Improve this Doc
IsNegativeInfinity
Declaration
public readonly bool IsNegativeInfinity { get; }
Property Value
|
Improve this Doc
Kind
Declaration
public readonly DateTimeKind Kind { get; }
Property Value
|
Improve this Doc
Millisecond
Declaration
public readonly int Millisecond { get; }
Property Value
|
Improve this Doc
Minute
Declaration
public readonly int Minute { get; }
Property Value
|
Improve this Doc
Month
Declaration
public readonly int Month { get; }
Property Value
|
Improve this Doc
Now
Declaration
public static readonly NpgsqlDateTime Now { get; }
Property Value
|
Improve this Doc
Second
Declaration
public readonly int Second { get; }
Property Value
|
Improve this Doc
Ticks
Declaration
public readonly long Ticks { get; }
Property Value
|
Improve this Doc
Time
Declaration
public readonly TimeSpan Time { get; }
Property Value
|
Improve this Doc
Year
Declaration
public readonly int Year { get; }
Property Value
Methods
|
Improve this Doc
Add(NpgsqlTimeSpan)
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
Returns
|
Improve this Doc
Compare(Object, Object)
Declaration
public readonly int Compare(object x, object y)
Parameters
Returns
|
Improve this Doc
CompareTo(NpgsqlDateTime)
Declaration
public readonly int CompareTo(NpgsqlDateTime other)
Parameters
Returns
|
Improve this Doc
CompareTo(Object)
Declaration
public readonly int CompareTo(object o)
Parameters
Type |
Name |
Description |
Object |
o |
|
Returns
|
Improve this Doc
Equals(NpgsqlDateTime)
Declaration
public readonly bool Equals(NpgsqlDateTime other)
Parameters
Returns
|
Improve this Doc
Equals(Object)
Declaration
public override readonly bool Equals(object obj)
Parameters
Type |
Name |
Description |
Object |
obj |
|
Returns
Overrides
|
Improve this Doc
GetHashCode()
Declaration
public override readonly int GetHashCode()
Returns
Overrides
|
Improve this Doc
Normalize()
Declaration
public readonly NpgsqlDateTime Normalize()
Returns
|
Improve this Doc
Parse(String)
Declaration
public static NpgsqlDateTime Parse(string str)
Parameters
Type |
Name |
Description |
String |
str |
|
Returns
|
Improve this Doc
Subtract(NpgsqlDateTime)
Declaration
public readonly NpgsqlTimeSpan Subtract(NpgsqlDateTime timestamp)
Parameters
Returns
|
Improve this Doc
Subtract(NpgsqlTimeSpan)
Declaration
public readonly NpgsqlDateTime Subtract(NpgsqlTimeSpan interval)
Parameters
Returns
|
Improve this Doc
ToDateTime()
Declaration
public readonly DateTime ToDateTime()
Returns
|
Improve this Doc
ToLocalTime()
Converts the value of the current NpgsqlDateTime object to local time.
Declaration
public readonly NpgsqlDateTime ToLocalTime()
Returns
|
Improve this Doc
ToNpgsqlDateTime(DateTime)
Declaration
public static NpgsqlDateTime ToNpgsqlDateTime(DateTime dateTime)
Parameters
Returns
|
Improve this Doc
ToString()
Declaration
public override readonly string ToString()
Returns
Overrides
|
Improve this Doc
ToUniversalTime()
Converts the value of the current NpgsqlDateTime object to Coordinated Universal Time (UTC).
Declaration
public readonly NpgsqlDateTime ToUniversalTime()
Returns
Operators
|
Improve this Doc
Addition(NpgsqlDateTime, NpgsqlTimeSpan)
Declaration
public static NpgsqlDateTime operator +(NpgsqlDateTime timestamp, NpgsqlTimeSpan interval)
Parameters
Returns
|
Improve this Doc
Addition(NpgsqlTimeSpan, NpgsqlDateTime)
Declaration
public static NpgsqlDateTime operator +(NpgsqlTimeSpan interval, NpgsqlDateTime timestamp)
Parameters
Returns
|
Improve this Doc
Equality(NpgsqlDateTime, NpgsqlDateTime)
Declaration
public static bool operator ==(NpgsqlDateTime x, NpgsqlDateTime y)
Parameters
Returns
|
Improve this Doc
Explicit(NpgsqlDateTime to DateTime)
Declaration
public static explicit operator DateTime(NpgsqlDateTime npgsqlDateTime)
Parameters
Returns
|
Improve this Doc
GreaterThan(NpgsqlDateTime, NpgsqlDateTime)
Declaration
public static bool operator>(NpgsqlDateTime x, NpgsqlDateTime y)
Parameters
Returns
|
Improve this Doc
GreaterThanOrEqual(NpgsqlDateTime, NpgsqlDateTime)
Declaration
public static bool operator >=(NpgsqlDateTime x, NpgsqlDateTime y)
Parameters
Returns
|
Improve this Doc
Implicit(DateTime to NpgsqlDateTime)
Declaration
public static implicit operator NpgsqlDateTime(DateTime dateTime)
Parameters
Returns
|
Improve this Doc
Inequality(NpgsqlDateTime, NpgsqlDateTime)
Declaration
public static bool operator !=(NpgsqlDateTime x, NpgsqlDateTime y)
Parameters
Returns
|
Improve this Doc
LessThan(NpgsqlDateTime, NpgsqlDateTime)
Declaration
public static bool operator <(NpgsqlDateTime x, NpgsqlDateTime y)
Parameters
Returns
|
Improve this Doc
LessThanOrEqual(NpgsqlDateTime, NpgsqlDateTime)
Declaration
public static bool operator <=(NpgsqlDateTime x, NpgsqlDateTime y)
Parameters
Returns
|
Improve this Doc
Subtraction(NpgsqlDateTime, NpgsqlDateTime)
Declaration
public static NpgsqlTimeSpan operator -(NpgsqlDateTime x, NpgsqlDateTime y)
Parameters
Returns
|
Improve this Doc
Subtraction(NpgsqlDateTime, NpgsqlTimeSpan)
Declaration
public static NpgsqlDateTime operator -(NpgsqlDateTime timestamp, NpgsqlTimeSpan interval)
Parameters
Returns
Implements