SqlDateTime SqlDateTime SqlDateTime SqlDateTime Struct

定义

表示要存储在数据库中或从数据库中检索的日期和时间数据,值范围介于 1753 年 1 月 1 日到 9999 年 12 月 31 日之间,精度为 3.33 毫秒。Represents the date and time data ranging in value from January 1, 1753 to December 31, 9999 to an accuracy of 3.33 milliseconds to be stored in or retrieved from a database. SqlDateTime 结构具有与其相应的 .NET Framework 类型 DateTime 不同的基础数据类型,该结构可以表示 12:00:00 AM 1/1/0001 和 11:59:59 PM 12/31/9999 之间的任何时间,精度可达到 100 毫微秒。The SqlDateTime structure has a different underlying data structure from its corresponding .NET Framework type, DateTime, which can represent any time between 12:00:00 AM 1/1/0001 and 11:59:59 PM 12/31/9999, to the accuracy of 100 nanoseconds. SqlDateTime 实际上存储的是相对于 00:00:00 AM 1/1/1900 的差值。SqlDateTime actually stores the relative difference to 00:00:00 AM 1/1/1900. 因此,将“00:00:00 AM 1/1/1900”转换为整数将返回 0。Therefore, a conversion from "00:00:00 AM 1/1/1900" to an integer will return 0.

public value class SqlDateTime : IComparable, System::Data::SqlTypes::INullable, System::Xml::Serialization::IXmlSerializable
[System.Serializable]
public struct SqlDateTime : IComparable, System.Data.SqlTypes.INullable, System.Xml.Serialization.IXmlSerializable
type SqlDateTime = struct
    interface INullable
    interface IXmlSerializable
Public Structure SqlDateTime
Implements IComparable, INullable, IXmlSerializable
继承
SqlDateTimeSqlDateTimeSqlDateTimeSqlDateTime
属性
实现

构造函数

SqlDateTime(DateTime) SqlDateTime(DateTime) SqlDateTime(DateTime) SqlDateTime(DateTime)

使用指定的 DateTime 值初始化 SqlDateTime 结构的新实例。Initializes a new instance of the SqlDateTime structure using the specified DateTime value.

SqlDateTime(Int32, Int32) SqlDateTime(Int32, Int32) SqlDateTime(Int32, Int32) SqlDateTime(Int32, Int32)

使用提供的参数初始化 SqlDateTime 结构的新实例。Initializes a new instance of the SqlDateTime structure using the supplied parameters.

SqlDateTime(Int32, Int32, Int32) SqlDateTime(Int32, Int32, Int32) SqlDateTime(Int32, Int32, Int32) SqlDateTime(Int32, Int32, Int32)

通过使用提供的参数初始化年、月、日,来初始化 SqlDateTime 结构的新实例。Initializes a new instance of the SqlDateTime structure using the supplied parameters to initialize the year, month, day.

SqlDateTime(Int32, Int32, Int32, Int32, Int32, Int32) SqlDateTime(Int32, Int32, Int32, Int32, Int32, Int32) SqlDateTime(Int32, Int32, Int32, Int32, Int32, Int32) SqlDateTime(Int32, Int32, Int32, Int32, Int32, Int32)

通过使用所提供的参数初始化新结构的年、月、日、小时、分钟和秒,来初始化 SqlDateTime 结构的新实例。Initializes a new instance of the SqlDateTime structure using the supplied parameters to initialize the year, month, day, hour, minute, and second of the new structure.

SqlDateTime(Int32, Int32, Int32, Int32, Int32, Int32, Double) SqlDateTime(Int32, Int32, Int32, Int32, Int32, Int32, Double) SqlDateTime(Int32, Int32, Int32, Int32, Int32, Int32, Double) SqlDateTime(Int32, Int32, Int32, Int32, Int32, Int32, Double)

通过使用所提供的参数初始化新结构的年、月、日、小时、分钟、秒和毫秒,来初始化 SqlDateTime 结构的新实例。Initializes a new instance of the SqlDateTime structure using the supplied parameters to initialize the year, month, day, hour, minute, second, and millisecond of the new structure.

SqlDateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32) SqlDateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32) SqlDateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32) SqlDateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32)

通过使用所提供的参数初始化新结构的年、月、日、小时、分钟、秒和毫秒,来初始化 SqlDateTime 结构的新实例。Initializes a new instance of the SqlDateTime structure using the supplied parameters to initialize the year, month, day, hour, minute, second, and microsecond of the new structure.

字段

MaxValue MaxValue MaxValue MaxValue

表示 SqlDateTime 结构的最大有效日期值。Represents the maximum valid date value for a SqlDateTime structure.

MinValue MinValue MinValue MinValue

表示 SqlDateTime 结构的最小有效日期值。Represents the minimum valid date value for a SqlDateTime structure.

Null Null Null Null

表示可指派给 DBNull 结构的此实例的 SqlDateTimeRepresents a DBNull that can be assigned to this instance of the SqlDateTime structure.

SQLTicksPerHour SQLTicksPerHour SQLTicksPerHour SQLTicksPerHour

值为等效于 1 小时的刻度数的常数。A constant whose value is the number of ticks equivalent to one hour.

SQLTicksPerMinute SQLTicksPerMinute SQLTicksPerMinute SQLTicksPerMinute

值为等效于 1 分钟的刻度数的常数。A constant whose value is the number of ticks equivalent to one minute.

SQLTicksPerSecond SQLTicksPerSecond SQLTicksPerSecond SQLTicksPerSecond

值为等效于 1 秒的刻度数的常数。A constant whose value is the number of ticks equivalent to one second.

属性

DayTicks DayTicks DayTicks DayTicks

获取刻度数,它表示此 SqlDateTime 结构的日期。Gets the number of ticks representing the date of this SqlDateTime structure.

IsNull IsNull IsNull IsNull

指示此 SqlDateTime 结构是否为 null。Indicates whether this SqlDateTime structure is null.

TimeTicks TimeTicks TimeTicks TimeTicks

获取表示此 SqlDateTime 结构的时间的刻度数。Gets the number of ticks representing the time of this SqlDateTime structure.

Value Value Value Value

获取 SqlDateTime 结构的值。Gets the value of the SqlDateTime structure. 此属性是只读的。This property is read-only.

方法

Add(SqlDateTime, TimeSpan) Add(SqlDateTime, TimeSpan) Add(SqlDateTime, TimeSpan) Add(SqlDateTime, TimeSpan)

向指定的 SqlDateTime 添加一个 TimeSpanAdds a SqlDateTime to the specified TimeSpan.

CompareTo(SqlDateTime) CompareTo(SqlDateTime) CompareTo(SqlDateTime) CompareTo(SqlDateTime)

将此 SqlDateTime 结构与提供的 SqlDateTime 结构进行比较,并返回其相对值的指示值。Compares this SqlDateTime structure to the supplied SqlDateTime structure and returns an indication of their relative values.

CompareTo(Object) CompareTo(Object) CompareTo(Object) CompareTo(Object)

将此 SqlDateTime 结构与提供的 Object 进行比较,并返回其相对值的指示值。Compares this SqlDateTime structure to the supplied Object and returns an indication of their relative values.

Equals(SqlDateTime, SqlDateTime) Equals(SqlDateTime, SqlDateTime) Equals(SqlDateTime, SqlDateTime) Equals(SqlDateTime, SqlDateTime)

对两个 SqlDateTime 结构执行逻辑比较,以确定它们是否相等。Performs a logical comparison of two SqlDateTime structures to determine whether they are equal.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

将提供的对象参数与 Value 对象的 SqlDateTime 属性进行比较。Compares the supplied object parameter to the Value property of the SqlDateTime object.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

获取此实例的哈希代码。Gets the hash code for this instance.

GetXsdType(XmlSchemaSet) GetXsdType(XmlSchemaSet) GetXsdType(XmlSchemaSet) GetXsdType(XmlSchemaSet)

返回指定的 XmlSchemaSet 的 XML 架构定义语言 (XSD)。Returns the XML Schema definition language (XSD) of the specified XmlSchemaSet.

GreaterThan(SqlDateTime, SqlDateTime) GreaterThan(SqlDateTime, SqlDateTime) GreaterThan(SqlDateTime, SqlDateTime) GreaterThan(SqlDateTime, SqlDateTime)

SqlDateTime 的两个实例进行比较,以确定第一个实例是否大于第二个实例。Compares two instances of SqlDateTime to determine whether the first is greater than the second.

GreaterThanOrEqual(SqlDateTime, SqlDateTime) GreaterThanOrEqual(SqlDateTime, SqlDateTime) GreaterThanOrEqual(SqlDateTime, SqlDateTime) GreaterThanOrEqual(SqlDateTime, SqlDateTime)

SqlDateTime 的两个实例进行比较,以确定第一个实例是否大于或等于第二个实例。Compares two instances of SqlDateTime to determine whether the first is greater than or equal to the second.

LessThan(SqlDateTime, SqlDateTime) LessThan(SqlDateTime, SqlDateTime) LessThan(SqlDateTime, SqlDateTime) LessThan(SqlDateTime, SqlDateTime)

SqlDateTime 的两个实例进行比较,以确定第一个实例是否小于第二个实例。Compares two instances of SqlDateTime to determine whether the first is less than the second.

LessThanOrEqual(SqlDateTime, SqlDateTime) LessThanOrEqual(SqlDateTime, SqlDateTime) LessThanOrEqual(SqlDateTime, SqlDateTime) LessThanOrEqual(SqlDateTime, SqlDateTime)

SqlDateTime 的两个实例进行比较,以确定第一个实例是否小于或等于第二个实例。Compares two instances of SqlDateTime to determine whether the first is less than or equal to the second.

NotEquals(SqlDateTime, SqlDateTime) NotEquals(SqlDateTime, SqlDateTime) NotEquals(SqlDateTime, SqlDateTime) NotEquals(SqlDateTime, SqlDateTime)

SqlDateTime 的两个实例执行逻辑比较,确定它们是否相等。Performs a logical comparison of two instances of SqlDateTime to determine whether they are not equal.

Parse(String) Parse(String) Parse(String) Parse(String)

将日期和时间的指定的 String 表示形式转换为其等效的 SqlDateTime 形式。Converts the specified String representation of a date and time to its SqlDateTime equivalent.

Subtract(SqlDateTime, TimeSpan) Subtract(SqlDateTime, TimeSpan) Subtract(SqlDateTime, TimeSpan) Subtract(SqlDateTime, TimeSpan)

从此 SqlDateTime 实例中减去指定的 TimespanSubtracts the specified Timespan from this SqlDateTime instance.

ToSqlString() ToSqlString() ToSqlString() ToSqlString()

将此 SqlDateTime 结构转换为 SqlStringConverts this SqlDateTime structure to SqlString.

ToString() ToString() ToString() ToString()

将此 SqlDateTime 结构转换为 StringConverts this SqlDateTime structure to a String.

操作员

Addition(SqlDateTime, TimeSpan) Addition(SqlDateTime, TimeSpan) Addition(SqlDateTime, TimeSpan) Addition(SqlDateTime, TimeSpan)

将提供的 TimeSpan 参数 t 指示的一段时间添加到提供的 SqlDateTime 结构中。Adds the period of time indicated by the supplied TimeSpan parameter, t, to the supplied SqlDateTime structure.

Equality(SqlDateTime, SqlDateTime) Equality(SqlDateTime, SqlDateTime) Equality(SqlDateTime, SqlDateTime) Equality(SqlDateTime, SqlDateTime)

对两个 SqlDateTime 结构执行逻辑比较,以确定它们是否相等。Performs a logical comparison of two SqlDateTime structures to determine whether they are equal.

Explicit(SqlDateTime to DateTime) Explicit(SqlDateTime to DateTime) Explicit(SqlDateTime to DateTime) Explicit(SqlDateTime to DateTime)

SqlDateTime 结构转换为 DateTime 结构。Converts the SqlDateTime structure to a DateTime structure.

Explicit(SqlString to SqlDateTime) Explicit(SqlString to SqlDateTime) Explicit(SqlString to SqlDateTime) Explicit(SqlString to SqlDateTime)

SqlString 参数转换为 SqlDateTimeConverts the SqlString parameter to a SqlDateTime.

GreaterThan(SqlDateTime, SqlDateTime) GreaterThan(SqlDateTime, SqlDateTime) GreaterThan(SqlDateTime, SqlDateTime) GreaterThan(SqlDateTime, SqlDateTime)

SqlDateTime 的两个实例进行比较,以确定第一个实例是否大于第二个实例。Compares two instances of SqlDateTime to determine whether the first is greater than the second.

GreaterThanOrEqual(SqlDateTime, SqlDateTime) GreaterThanOrEqual(SqlDateTime, SqlDateTime) GreaterThanOrEqual(SqlDateTime, SqlDateTime) GreaterThanOrEqual(SqlDateTime, SqlDateTime)

SqlDateTime 的两个实例进行比较,以确定第一个实例是否大于或等于第二个实例。Compares two instances of SqlDateTime to determine whether the first is greater than or equal to the second.

Implicit(DateTime to SqlDateTime) Implicit(DateTime to SqlDateTime) Implicit(DateTime to SqlDateTime) Implicit(DateTime to SqlDateTime)

DateTime 结构转换为 SqlDateTime 结构。Converts a DateTime structure to a SqlDateTime structure.

Inequality(SqlDateTime, SqlDateTime) Inequality(SqlDateTime, SqlDateTime) Inequality(SqlDateTime, SqlDateTime) Inequality(SqlDateTime, SqlDateTime)

SqlDateTime 的两个实例执行逻辑比较,确定它们是否相等。Performs a logical comparison of two instances of SqlDateTime to determine whether they are not equal.

LessThan(SqlDateTime, SqlDateTime) LessThan(SqlDateTime, SqlDateTime) LessThan(SqlDateTime, SqlDateTime) LessThan(SqlDateTime, SqlDateTime)

SqlDateTime 的两个实例进行比较,以确定第一个实例是否小于第二个实例。Compares two instances of SqlDateTime to determine whether the first is less than the second.

LessThanOrEqual(SqlDateTime, SqlDateTime) LessThanOrEqual(SqlDateTime, SqlDateTime) LessThanOrEqual(SqlDateTime, SqlDateTime) LessThanOrEqual(SqlDateTime, SqlDateTime)

SqlDateTime 的两个实例进行比较,以确定第一个实例是否小于或等于第二个实例。Compares two instances of SqlDateTime to determine whether the first is less than or equal to the second.

Subtraction(SqlDateTime, TimeSpan) Subtraction(SqlDateTime, TimeSpan) Subtraction(SqlDateTime, TimeSpan) Subtraction(SqlDateTime, TimeSpan)

从提供的 TimeSpan 结构中减去提供的 SqlDateTime 结构 tSubtracts the supplied TimeSpan structure, t, from the supplied SqlDateTime structure.

显式界面实现

IXmlSerializable.GetSchema() IXmlSerializable.GetSchema() IXmlSerializable.GetSchema() IXmlSerializable.GetSchema()

此成员支持 .NET Framework 结构,不能在代码中直接使用。This member supports the .NET Framework infrastructure and is not intended to be used directly from your code.

IXmlSerializable.ReadXml(XmlReader) IXmlSerializable.ReadXml(XmlReader) IXmlSerializable.ReadXml(XmlReader) IXmlSerializable.ReadXml(XmlReader)

此成员支持 .NET Framework 结构,不能在代码中直接使用。This member supports the .NET Framework infrastructure and is not intended to be used directly from your code.

IXmlSerializable.WriteXml(XmlWriter) IXmlSerializable.WriteXml(XmlWriter) IXmlSerializable.WriteXml(XmlWriter) IXmlSerializable.WriteXml(XmlWriter)

此成员支持 .NET Framework 结构,不能在代码中直接使用。This member supports the .NET Framework infrastructure and is not intended to be used directly from your code.

适用于

另请参阅