Oracle® Data Provider for .NET Developer's Guide 11g Release 1 (11.1) Part Number B28375-01 |
|
|
View PDF |
The OracleTimeStamp
structure represents the Oracle TIMESTAMP
data type to be stored in or retrieved from a database. Each OracleTimeStamp
stores the following information: year, month, day, hour, minute, second, and nanosecond.
Class Inheritance
System.Object
System.ValueType
Oracle.DataAccess.Types.OracleTimeStamp
Declaration
// ADO.NET 2.0: C#public struct OracleTimeStamp : IComparable, INullable, IXmlSerializable
// ADO.NET 1.x: C#
public struct OracleTimeStamp : IComparable, INullable
Thread Safety
All public static methods are thread-safe, although instance methods do not guarantee thread safety.
Example
// C# using System; using Oracle.DataAccess.Types; class OracleTimeStampSample { static void Main() { OracleTimeStamp tsCurrent1 = OracleTimeStamp.GetSysDate(); OracleTimeStamp tsCurrent2 = DateTime.Now; // Calculate the difference between tsCurrent1 and tsCurrent2 OracleIntervalDS idsDiff = tsCurrent2.GetDaysBetween(tsCurrent1); // Calculate the difference using AddNanoseconds() int nanoDiff = 0; while (tsCurrent2 > tsCurrent1) { nanoDiff += 10; tsCurrent1 = tsCurrent1.AddNanoseconds(10); } Console.WriteLine("idsDiff.Nanoseconds = " + idsDiff.Nanoseconds); Console.WriteLine("nanoDiff = " + nanoDiff); } }
Requirements
Namespace: Oracle.DataAccess.Types
Assembly: Oracle.DataAccess.dll
Microsoft .NET Framework Version: 1.x or 2.0
See Also:
OracleTimeStamp
members are listed in the following tables:
OracleTimeStamp Constructors
OracleTimeStamp
constructors are listed in Table 12-87
Table 12-87 OracleTimeStamp Constructors
Constructor | Description |
---|---|
Instantiates a new instance of |
OracleTimeStamp Static Fields
The OracleTimeStamp
static fields are listed in Table 12-88.
Table 12-88 OracleTimeStamp Static Fields
Field | Description |
---|---|
Represents the maximum valid date for an |
|
Represents the minimum valid date for an |
|
Represents a null value that can be assigned to an instance of the |
OracleTimeStamp Static Methods
The OracleTimeStamp
static methods are listed in Table 12-89.
Table 12-89 OracleTimeStamp Static Methods
Methods | Description |
---|---|
Determines if two |
|
Determines if the first of two |
|
Determines if the first of two |
|
Determines if the first of two |
|
Determines if the first of two |
|
Determines if two |
|
Gets an |
|
Gets an |
|
Returns a new instance of an |
OracleTimeStamp Static Operators
The OracleTimeStamp
static operators are listed in Table 12-90.
Table 12-90 OracleTimeStamp Static Operators
Operator | Description |
---|---|
Adds the supplied instance value to the supplied |
|
Determines if two |
|
Determines if the first of two |
|
Determines if the first of two |
|
Determines if the two |
|
Determines if the first of two |
|
Determines if the first of two |
|
Subtracts the supplied instance value from the supplied |
OracleTimeStamp Static Type Conversions
The OracleTimeStamp
static type conversions are listed in Table 12-91.
Table 12-91 OracleTimeStamp Static Type Conversions
Operator | Description |
---|---|
Converts an instance value to an |
|
Converts an instance value to an |
|
Converts an |
OracleTimeStamp Properties
The OracleTimeStamp
properties are listed in Table 12-92.
Table 12-92 OracleTimeStamp Properties
Properties | Description |
---|---|
Returns an array of bytes that represents an Oracle |
|
Specifies the day component of an |
|
Indicates whether or not the |
|
Specifies the hour component of an |
|
Specifies the millisecond component of an |
|
Specifies the minute component of an |
|
Specifies the month component of an |
|
Specifies the nanosecond component of an |
|
Specifies the second component of an |
|
Specifies the date and time that is stored in the |
|
Specifies the year component of an |
OracleTimeStamp Methods
The OracleTimeStamp
methods are listed in Table 12-93.
Table 12-93 OracleTimeStamp Methods
Methods | Description |
---|---|
Adds the supplied number of days to the current instance |
|
Adds the supplied number of hours to the current instance |
|
Adds the supplied number of milliseconds to the current instance |
|
Adds the supplied number of minutes to the current instance |
|
Adds the supplied number of months to the current instance |
|
Adds the supplied number of nanoseconds to the current instance |
|
Adds the supplied number of seconds to the current instance |
|
Adds the supplied number of years to the current instance |
|
Compares the current |
|
Determines whether or not an object has the same date and time as the current |
|
Returns a hash code for the |
|
Subtracts an |
|
Subtracts |
|
GetType |
Inherited from |
Converts the current |
|
Converts the current |
|
Converts the current |
|
Converts the current |
The OracleTimeStamp
constructors create new instances of the OracleTimeStamp
structure.
Overload List:
This constructor creates a new instance of the OracleTimeStamp
structure and sets its value for date and time using the supplied DateTime
value.
This constructor creates a new instance of the OracleTimeStamp
structure and sets its value using the supplied string.
OracleTimeStamp(int, int, int)
This constructor creates a new instance of the OracleTimeStamp
structure and sets its value for date using year, month, and day.
OracleTimeStamp(int, int, int, int, int, int)
This constructor creates a new instance of the OracleTimeStamp
structure and sets its value for date and time using year, month, day, hour, minute, and second.
OracleTimeStamp(int, int, int, int, int, int, double)
This constructor creates a new instance of the OracleTimeStamp
structure and sets its value for date and time using year, month, day, hour, minute, second, and millisecond.
OracleTimeStamp(int, int, int, int, int, int, int)
This constructor creates a new instance of the OracleTimeStamp
structure and sets its value for date and time using year, month, day, hour, minute, second, and nanosecond.
This constructor creates a new instance of the OracleTimeStamp
structure and sets its value to the provided byte array, which is in the internal Oracle TIMESTAMP
format.
This constructor creates a new instance of the OracleTimeStamp
structure and sets its value for date and time using the supplied DateTime
value.
Declaration
// C#
public OracleTimeStamp (DateTime dt);
Parameters
dt
The supplied DateTime
value.
Exceptions
ArgumentException
- The dt
parameter cannot be used to construct a valid OracleTimeStamp
.
This constructor creates a new instance of the OracleTimeStamp
structure and sets its value using the supplied string.
Declaration
// C#
public OracleTimeStamp (string tsStr);
Parameters
tsStr
A string that represents an Oracle TIMESTAMP
.
Exceptions
ArgumentException
- The tsStr
value is an invalid string representation of an Oracle TIMESTAMP
or the supplied tsStr
is not in the timestamp format specified by the OracleGlobalization
.TimeStampFormat
property of the thread, which represents the Oracle NLS_TIMESTAMP_FORMAT
parameter.
ArgumentNullException
- The tsStr
value is null.
Remarks
The names and abbreviations used for months and days are in the language specified by the DateLanguage
and Calendar
properties of the thread's OracleGlobalization
object. If any of the thread's globalization properties are set to null or an empty string, the client computer's settings are used.
Example
// C# using System; using Oracle.DataAccess.Types; using Oracle.DataAccess.Client; class OracleTimeStampSample { static void Main() { // Set the nls_timestamp_format for the OracleTimeStamp(string) // constructor OracleGlobalization info = OracleGlobalization.GetClientInfo(); info.TimeStampFormat = "DD-MON-YYYY HH:MI:SS.FF AM"; OracleGlobalization.SetThreadInfo(info); // construct OracleTimeStamp from a string using the format specified. OracleTimeStamp ts = new OracleTimeStamp("11-NOV-1999 11:02:33.444 AM"); // Set the nls_timestamp_format for the ToString() method info.TimeStampFormat = "YYYY-MON-DD HH:MI:SS.FF AM"; OracleGlobalization.SetThreadInfo(info); // Prints "1999-NOV-11 11:02:33.444000000 AM" Console.WriteLine(ts.ToString()); } }
See Also:
Oracle Database SQL Language Reference for further information on date format elements
This constructor creates a new instance of the OracleTimeStamp
structure and sets its value for date using year, month, and day.
Declaration
// C# public OracleTimeStamp(int year, int month, int day);
Parameters
year
The year provided. Range of year
is (-4712 to 9999).
month
The month provided. Range of month
is (1 to 12).
day
The day provided. Range of day
is (1 to 31).
Exceptions
ArgumentOutOfRangeException
- The argument value for one or more of the parameters is out of the specified range.
ArgumentException
- The argument values of the parameters cannot be used to construct a valid OracleTimeStamp
(that is, the day is out of range for the month).
This constructor creates a new instance of the OracleTimeStamp
structure and sets its value for date and time using year, month, day, hour, minute, and second.
Declaration
// C# public OracleTimeStamp (int year, int month, int day, int hour, int minute, int second);
Parameters
year
The year provided. Range of year
is (-4712 to 9999).
month
The month provided. Range of month
is (1 to 12).
day
The day provided. Range of day
is (1 to 31).
hour
The hour provided. Range of hour
is (0 to 23).
minute
The minute provided. Range of minute
is (0 to 59).
second
The second provided. Range of second
is (0 to 59).
Exceptions
ArgumentOutOfRangeException
- The argument value for one or more of the parameters is out of the specified range.
ArgumentException
- The argument values of the parameters cannot be used to construct a valid OracleTimeStamp
(that is, the day is out of range for the month).
This constructor creates a new instance of the OracleTimeStamp
structure and sets its value for date and time using year, month, day, hour, minute, second, and millisecond.
Declaration
// C# public OracleTimeStamp(int year, int month, int day, int hour, int minute, int second, double millisecond);
Parameters
year
The year provided. Range of year
is (-4712 to 9999).
month
The month provided. Range of month
is (1 to 12).
day
The day provided. Range of day
is (1 to 31).
hour
The hour provided. Range of hour
is (0 to 23).
minute
The minute provided. Range of minute
is (0 to 59).
second
The second provided. Range of second
is (0 to 59).
milliSeconds
The milliseconds provided. Range of millisecond
is (0 to 999.999999).
Exceptions
ArgumentOutOfRangeException
- The argument value for one or more of the parameters is out of the specified range.
ArgumentException
- The argument values of the parameters cannot be used to construct a valid OracleTimeStamp
(that is, the day is out of range for the month).
This constructor creates a new instance of the OracleTimeStamp
structure and sets its value for date and time using year, month, day, hour, minute, second, and nanosecond.
Declaration
// C# public OracleTimeStamp (int year, int month, int day, int hour, int minute, int second, int nanosecond);
Parameters
year
The year provided. Range of year
is (-4712 to 9999).
month
The month provided. Range of month
is (1 to 12).
day
The day provided. Range of day
is (1 to 31).
hour
The hour provided. Range of hour
is (0 to 23).
minute
The minute provided. Range of minute
is (0 to 59).
second
The second provided. Range of second
is (0 to 59).
nanosecond
The nanosecond provided. Range of nanosecond
is (0 to 999999999).
Exceptions
ArgumentOutOfRangeException
- The argument value for one or more of the parameters is out of the specified range.
ArgumentException
- The argument values of the parameters cannot be used to construct a valid OracleTimeStamp
(that is, the day is out of range for the month).
This constructor creates a new instance of the OracleTimeStamp
structure and sets its value to the provided byte array, which is in the internal Oracle TIMESTAMP
format.
Declaration
// C#
public OracleTimeStamp (byte[] bytes);
Parameters
bytes
A byte array that represents an Oracle TIMESTAMP
in Oracle internal format.
Exceptions
ArgumentException
- bytes
is not in an internal Oracle TIMESTAMP
format or bytes
is not a valid Oracle TIMESTAMP
.
ArgumentNullException
- bytes
is null.
The OracleTimeStamp
static fields are listed in Table 12-94.
Table 12-94 OracleTimeStamp Static Fields
Field | Description |
---|---|
Represents the maximum valid date for an |
|
Represents the minimum valid date for an |
|
Represents a null value that can be assigned to an instance of the |
This static field represents the maximum valid date and time for an OracleTimeStamp
structure, which is December 31, 9999 23:59:59.999999999.
Declaration
// C# public static readonly OraTimestamp MaxValue;
This static field represents the minimum valid date and time for an OracleTimeStamp
structure, which is January 1, -4712 0:0:0.
Declaration
// C# public static readonly OracleTimeStamp MinValue;
This static field represents a null value that can be assigned to an instance of the OracleTimeStamp
structure.
Declaration
// C# public static readonly OracleTimeStamp Null;
The OracleTimeStamp
static methods are listed in Table 12-95.
Table 12-95 OracleTimeStamp Static Methods
Methods | Description |
---|---|
Determines if two |
|
Determines if the first of two |
|
Determines if the first of two |
|
Determines if the first of two |
|
Determines if the first of two |
|
Determines if two |
|
Gets an |
|
Gets an |
|
Returns a new instance of an |
This static method determines if two OracleTimeStamp
values are equal.
Declaration
// C# public static bool Equals(OracleTimeStamp value1, OracleTimeStamp value2);
Parameters
value1
The first OracleTimeStamp
.
value2
The second OracleTimeStamp
.
Return Value
Returns true
if two OracleTimeStamp
values are equal; otherwise, returns false
.
Remarks
The following rules apply to the behavior of this method.
Any OracleTimeStamp
that has a value is greater than an OracleTimeStamp
that has a null value.
Two OracleTimeStamp
s that contain a null value are equal.
This static method determines if the first of two OracleTimeStamp
values is greater than the second.
Declaration
// C# public static bool GreaterThan(OracleTimeStamp value1, OracleTimeStamp value2);
Parameters
value1
The first OracleTimeStamp
.
value2
The second OracleTimeStamp
.
Return Value
Returns true
if the first of two OracleTimeStamp
values is greater than the second; otherwise, returns false
.
Remarks
The following rules apply to the behavior of this method.
Any OracleTimeStamp
that has a value is greater than an OracleTimeStamp
that has a null value.
Two OracleTimeStamp
s that contain a null value are equal.
This static method determines if the first of two OracleTimeStamp
values is greater than or equal to the second.
Declaration
// C# public static bool GreaterThanOrEqual(OracleTimeStamp value1, OracleTimeStamp value2);
Parameters
value1
The first OracleTimeStamp
.
value2
The second OracleTimeStamp
.
Return Value
Returns true
if the first of two OracleTimeStamp
values is greater than or equal to the second; otherwise, returns false
.
Remarks
The following rules apply to the behavior of this method.
Any OracleTimeStamp
that has a value is greater than an OracleTimeStamp
that has a null value.
Two OracleTimeStamp
s that contain a null value are equal.
This static method determines if the first of two OracleTimeStamp
values is less than the second.
Declaration
// C# public static bool LessThan(OracleTimeStamp value1, OracleTimeStamp value2);
Parameters
value1
The first OracleTimeStamp
.
value2
The second OracleTimeStamp
.
Return Value
Returns true
if the first of two OracleTimeStamp
values is less than the second. Returns false
otherwise.
Remarks
The following rules apply to the behavior of this method.
Any OracleTimeStamp
that has a value is greater than an OracleTimeStamp
that has a null value.
Two OracleTimeStamp
s that contain a null value are equal.
This static method determines if the first of two OracleTimeStamp
values is less than or equal to the second.
Declaration
// C# public static bool LessThanOrEqual(OracleTimeStamp value1, OracleTimeStamp value2);
Parameters
value1
The first OracleTimeStamp
.
value2
The second OracleTimeStamp
.
Return Value
Returns true
if the first of two OracleTimeStamp
values is less than or equal to the second. Returns false
otherwise.
Remarks
The following rules apply to the behavior of this method.
Any OracleTimeStamp
that has a value is greater than an OracleTimeStamp
that has a null value.
Two OracleTimeStamp
s that contain a null value are equal.
This static method determines if two OracleTimeStamp
values are not equal.
Declaration
// C# public static bool NotEquals(OracleTimeStamp value1, OracleTimeStamp value2);
Parameters
value1
The first OracleTimeStamp
.
value2
The second OracleTimeStamp
.
Return Value
Returns true
if two OracleTimeStamp
values are not equal. Returns false
otherwise.
Remarks
The following rules apply to the behavior of this method.
Any OracleTimeStamp
that has a value is greater than an OracleTimeStamp
that has a null value.
Two OracleTimeStamp
s that contain a null value are equal.
This static method gets an OracleTimeStamp
structure that represents the current date and time.
Declaration
// C# public static OracleTimeStamp GetSysDate();
Return Value
An OracleTimeStamp
structure that represents the current date and time.
This static method gets an OracleTimeStamp
structure and sets its value using the supplied string.
Declaration
// C#
public static OracleTimeStamp Parse(string datetime);
Parameters
datetime
A string that represents an Oracle TIMESTAMP
.
Return Value
An OracleTimeStamp
structure.
Exceptions
ArgumentException
- The tsStr
is an invalid string representation of an Oracle TIMESTAMP
or the supplied tsStr
is not in the timestamp format specified by the OracleGlobalization
.TimeStampFormat
property of the thread, which represents the Oracle NLS_TIMESTAMP_FORMAT
parameter.
ArgumentNullException
- The tsStr
value is null.
Remarks
The names and abbreviations used for months and days are in the language specified by the DateLanguage
and Calendar
properties of the thread's OracleGlobalization
object. If any of the thread's globalization properties are set to null or an empty string, the client computer's settings are used.
Example
// C# using System; using Oracle.DataAccess.Types; using Oracle.DataAccess.Client; class ParseSample { static void Main() { // Set the nls_timestamp_format for the Parse() method OracleGlobalization info = OracleGlobalization.GetClientInfo(); info.TimeStampFormat = "DD-MON-YYYY HH:MI:SS.FF AM"; OracleGlobalization.SetThreadInfo(info); // construct OracleTimeStamp from a string using the format specified. OracleTimeStamp ts = OracleTimeStamp.Parse("11-NOV-1999 11:02:33.444 AM"); // Set the nls_timestamp_format for the ToString() method info.TimeStampFormat = "YYYY-MON-DD HH:MI:SS.FF AM"; OracleGlobalization.SetThreadInfo(info); // Prints "1999-NOV-11 11:02:33.444000000 AM" Console.WriteLine(ts.ToString()); } }
See Also:
This static method returns a new instance of an OracleTimeStamp
with the specified fractional second precision.
Declaration
// C# public static OracleTimeStamp SetPrecision(OracleTimeStamp value1, int fracSecPrecision);
Parameters
value1
The provided OracleTimeStamp
object.
fracSecPrecision
The fractional second precision provided. Range of fractional second precision is (0 to 9).
Return Value
An OracleTimeStamp
structure with the specified fractional second precision.
Exceptions
ArgumentOutOfRangeException
- fracSecPrecision
is out of the specified range.
Remarks
The value specified in the supplied fracSecPrecision
is used to perform a rounding off operation on the supplied OracleTimeStamp
value. Depending on this value, 0
or more trailing zeros are displayed in the string returned by ToString()
.
Example
The OracleTimeStamp
with a value of "December
31,
9999
23:59:59.99
" results in the string "December
31,
9999
23:59:59.99000
" when SetPrecision()
is called with the fractional second precision set to 5
.
The OracleTimeStamp
static operators are listed in Table 12-96.
Table 12-96 OracleTimeStamp Static Operators
Operator | Description |
---|---|
|
Adds the supplied instance value to the supplied |
|
Determines if two |
|
Determines if the first of two |
|
Determines if the first of two |
Determines if the two |
|
Determines if the first of two |
|
Determines if the first of two |
|
|
Subtracts the supplied instance value from the supplied |
operator+
adds the supplied object to the OracleTimeStamp
and returns a new OracleTimeStamp
structure.
Overload List:
operator + (OracleTimeStamp, OracleIntervalDS)
This static operator adds the supplied OracleIntervalDS
to the OracleTimeStamp
and returns a new OracleTimeStamp
structure.
operator + (OracleTimeStamp, OracleIntervalYM)
This static operator adds the supplied OracleIntervalYM
to the supplied OracleTimeStamp
and returns a new OracleTimeStamp
structure.
operator + (OracleTimeStamp, TimeSpan)
This static operator adds the supplied TimeSpan
to the supplied OracleTimeStamp
and returns a new OracleTimeStamp
structure.
This static operator adds the supplied OracleIntervalDS
to the OracleTimeStamp
and returns a new OracleTimeStamp
structure.
Declaration
// C# public static operator + (OracleTimeStamp value1, OracleIntervalDS value2);
Parameters
value1
An OracleTimeStamp
.
value2
An OracleIntervalDS
.
Return Value
An OracleTimeStamp.
Remarks
If either parameter has a null value, the returned OracleTimeStamp
has a null value.
This static operator adds the supplied OracleIntervalYM
to the supplied OracleTimeStamp
and returns a new OracleTimeStamp
structure.
Declaration
// C# public static operator + (OracleTimeStamp value1, OracleIntervalYM value2);
Parameters
value1
An OracleTimeStamp
.
value2
An OracleIntervalYM.
Return Value
An OracleTimeStamp
.
Remarks
If either parameter has a null value, the returned OracleTimeStamp
has a null value.
This static operator adds the supplied TimeSpan
to the supplied OracleTimeStamp
and returns a new OracleTimeStamp
structure.
Declaration
// C# public static operator + (OracleTimeStamp value1, TimeSpan value2);
Parameters
value1
An OracleTimeStamp
.
value2
A TimeSpan.
Return Value
An OracleTimeStamp.
Remarks
If the OracleTimeStamp
instance has a null value, the returned OracleTimeStamp
has a null value.
This static operator determines if two OracleTimeStamp
values are equal.
Declaration
// C# public static bool operator == (OracleTimeStamp value1, OracleTimeStamp value2);
Parameters
value1
The first OracleTimeStamp
.
value2
The second OracleTimeStamp
.
Return Value
Returns true
if they are the same; otherwise, returns false
.
Remarks
The following rules apply to the behavior of this method.
Any OracleTimeStamp
that has a value is greater than an OracleTimeStamp
that has a null value.
Two OracleTimeStamp
s that contain a null value are equal.
This static operator determines if the first of two OracleTimeStamp
values is greater than the second.
Declaration
// C# public static bool operator > (OracleTimeStamp value1, OracleTimeStamp value2);
Parameters
value1
The first OracleTimeStamp
.
value2
The second OracleTimeStamp
.
Return Value
Returns true
if the first OracleTimeStamp
value is greater than the second; otherwise, returns false
.
Remarks
The following rules apply to the behavior of this method.
Any OracleTimeStamp
that has a value is greater than an OracleTimeStamp
that has a null value.
Two OracleTimeStamp
s that contain a null value are equal.
This static operator determines if the first of two OracleTimeStamp
values is greater than or equal to the second.
Declaration
// C# public static bool operator >= (OracleTimeStamp value1, OracleTimeStamp value2);
Parameters
value1
The first OracleTimeStamp
.
value2
The second OracleTimeStamp
.
Return Value
Returns true
if the first OracleTimeStamp
is greater than or equal to the second; otherwise returns false
.
Remarks
The following rules apply to the behavior of this method.
Any OracleTimeStamp
that has a value is greater than an OracleTimeStamp
that has a null value.
Two OracleTimeStamp
s that contain a null value are equal.
This static operator determines if two OracleTimeStamp
values are not equal.
Declaration
// C# public static bool operator != (OracleTimeStamp value1, OracleTimeStamp value2);
Parameters
value1
The first OracleTimeStamp
.
value2
The second OracleTimeStamp
.
Return Value
Returns true
if two OracleTimeStamp
values are not equal; otherwise, returns false
.
Remarks
The following rules apply to the behavior of this method.
Any OracleTimeStamp
that has a value is greater than an OracleTimeStamp
that has a null value.
Two OracleTimeStamp
s that contain a null value are equal.
This static operator determines if the first of two OracleTimeStamp
values is less than the second.
Declaration
// C# public static bool operator < (OracleTimeStamp value1, OracleTimeStamp value2);
Parameters
value1
The first OracleTimeStamp
.
value2
The second OracleTimeStamp
.
Return Value
Returns true
if the first OracleTimeStamp
is less than the second; otherwise, returns false
.
Remarks
The following rules apply to the behavior of this method.
Any OracleTimeStamp
that has a value is greater than an OracleTimeStamp
that has a null value.
Two OracleTimeStamp
s that contain a null value are equal.
This static operator determines if the first of two OracleTimeStamp
values is less than or equal to the second.
Declaration
// C# public static bool operator <= (OracleTimeStamp value1, OracleTimeStamp value2);
Parameters
value1
The first OracleTimeStamp.
value2
The second OracleTimeStamp.
Return Value
Returns true
if the first OracleTimeStamp
is less than or equal to the second; otherwise, returns false
.
Remarks
The following rules apply to the behavior of this method.
Any OracleTimeStamp
that has a value is greater than an OracleTimeStamp
that has a null value.
Two OracleTimeStamp
s that contain a null value are equal.
operator-
subtracts the supplied value, from the supplied OracleTimeStamp
value, and returns a new OracleTimeStamp
structure.
Overload List:
operator - (OracleTimeStamp, OracleIntervalDS)
This static operator subtracts the supplied OracleIntervalDS
value, from the supplied OracleTimeStamp
value, and return a new OracleTimeStamp
structure.
operator - (OracleTimeStamp, OracleIntervalYM)
This static operator subtracts the supplied OracleIntervalYM
value, from the supplied OracleTimeStamp
value, and returns a new OracleTimeStamp
structure.
operator - (OracleTimeStamp, TimeSpan)
This static operator subtracts the supplied TimeSpan
value, from the supplied OracleTimeStamp
value, and returns a new OracleTimeStamp
structure.
This static operator subtracts the supplied OracleIntervalDS
value, from the supplied OracleTimeStamp
value, and return a new OracleTimeStamp
structure.
Declaration
// C# public static operator - (OracleTimeStamp value1, OracleIntervalDS value2);
Parameters
value1
An OracleTimeStamp
.
value2
An OracleIntervalDS
instance.
Return Value
An OracleTimeStamp
structure.
Remarks
If either parameter has a null value, the returned OracleTimeStamp
has a null value.
This static operator subtracts the supplied OracleIntervalYM
value, from the supplied OracleTimeStamp
value, and returns a new OracleTimeStamp
structure.
Declaration
// C# public static operator - (OracleTimeStamp value1, OracleIntervalYM value2);
Parameters
value1
An OracleTimeStamp
.
value2
An OracleIntervalYM
instance.
Return Value
An OracleTimeStamp
structure.
Remarks
If either parameter has a null value, the returned OracleTimeStamp
has a null value.
This static operator subtracts the supplied TimeSpan
value, from the supplied OracleTimeStamp
value, and returns a new OracleTimeStamp
structure.
Declaration
// C# public static operator - (OracleTimeStamp value1, TimeSpan value2);
Parameters
value1
An OracleTimeStamp
.
value2
A TimeSpan
instance.
Return Value
An OracleTimeStamp
structure.
Remarks
If the OracleTimeStamp
instance has a null value, the returned OracleTimeStamp
structure has a null value.
The OracleTimeStamp
static type conversions are listed in Table 12-97.
Table 12-97 OracleTimeStamp Static Type Conversions
Operator | Description |
---|---|
Converts an instance value to an |
|
Converts an instance value to an |
|
Converts an |
explicit operator OracleTimeStamp
converts the supplied value to an OracleTimeStamp
structure
Overload List:
explicit operator OracleTimeStamp(OracleTimeStampLTZ)
This static type conversion operator converts an OracleTimeStampLTZ
value to an OracleTimeStamp
structure.
explicit operator OracleTimeStamp(OracleTimeStampTZ)
This static type conversion operator converts an OracleTimeStampTZ
value to an OracleTimeStamp
structure.
explicit operator OracleTimeStamp(string)
This static type conversion operator converts the supplied string to an OracleTimeStamp
structure.
This static type conversion operator converts an OracleTimeStampLTZ
value to an OracleTimeStamp
structure.
Declaration
// C#
public static explicit operator OracleTimeStamp(OracleTimeStampLTZ value1);
Parameters
value1
An OracleTimeStampLTZ
instance.
Return Value
The returned OracleTimeStamp
contains the date and time of the OracleTimeStampLTZ
structure.
Remarks
If the OracleTimeStampLTZ
structure has a null value, the returned OracleTimeStamp
structure also has a null value.
This static type conversion operator converts an OracleTimeStampTZ
value to an OracleTimeStamp
structure.
Declaration
// C#
public static explicit operator OracleTimeStamp(OracleTimeStampTZ value1);
Parameters
value1
An OracleTimeStampTZ
instance.
Return Value
The returned OracleTimeStamp
contains the date and time information from value1
, but the time zone information from value1
is truncated.
Remarks
If the OracleTimeStampTZ
structure has a null value, the returned OracleTimeStamp
structure also has a null value.
This static type conversion operator converts the supplied string to an OracleTimeStamp
structure.
Declaration
// C#
public static explicit operator OracleTimeStamp(string tsStr);
Parameters
tsStr
A string representation of an Oracle TIMESTAMP
.
Return Value
An OracleTimeStamp
.
Exceptions
ArgumentException
- The tsStr
is an invalid string representation of an Oracle TIMESTAMP
or the tsStr
is not in the timestamp format specified by the thread's OracleGlobalization
.TimeStampFormat
property, which represents the Oracle NLS_TIMESTAMP_FORMAT
parameter.
Remarks
The names and abbreviations used for months and days are in the language specified by the DateLanguage
and Calendar
properties of the thread's OracleGlobalization
object. If any of the thread's globalization properties are set to null or an empty string, the client computer's settings are used.
Example
// C# using System; using Oracle.DataAccess.Types; using Oracle.DataAccess.Client; class OracleTimeStampSample { static void Main() { // Set the nls_timestamp_format for the explicit // operator OracleTimeStamp(string) OracleGlobalization info = OracleGlobalization.GetClientInfo(); info.TimeStampFormat = "DD-MON-YYYY HH:MI:SS.FF AM"; OracleGlobalization.SetThreadInfo(info); // construct OracleTimeStamp from a string using the format specified. OracleTimeStamp ts = new OracleTimeStamp("11-NOV-1999 11:02:33.444 AM"); // Set the nls_timestamp_format for the ToString method info.TimeStampFormat = "YYYY-MON-DD HH:MI:SS.FF AM"; OracleGlobalization.SetThreadInfo(info); // Prints "1999-NOV-11 11:02:33.444000000 AM" Console.WriteLine(ts.ToString()); } }
See Also:
Oracle Database SQL Language Reference for further information on datetime format elements
This static type conversion operator converts a value to an OracleTimeStamp
structure.
Overload List:
implicit operator OracleTimeStamp(OracleDate)
This static type conversion operator converts an OracleDate
value to an OracleTimeStamp
structure.
implicit operator OracleTimeStamp(DateTime)
This static type conversion operator converts a DateTime
value to an OracleTimeStamp
structure.
This static type conversion operator converts an OracleDate
value to an OracleTimeStamp
structure.
Declaration
// C#
public static implicit operator OracleTimeStamp (OracleDate value1);
Parameters
value1
An OracleDate
instance.
Return Value
An OracleTimeStamp
structure that contains the date and time of the OracleDate
structure, value1
.
Remarks
If the OracleDate
structure has a null value, the returned OracleTimeStamp
structure also has a null value.
This static type conversion operator converts a DateTime
value to an OracleTimeStamp
structure.
Declaration
// C#
public static implicit operator OracleTimeStamp(DateTime value);
Parameters
value
A DateTime
instance.
Return Value
An OracleTimeStamp
structure.
This static type conversion operator converts an OracleTimeStamp
value to a DateTime
structure.
Declaration
// C#
public static explicit operator DateTime(OracleTimeStamp value1);
Parameters
value1
An OracleTimeStamp
instance.
Return Value
A DateTime
containing the date and time in the current instance.
Exceptions
OracleNullValueException
- The OracleTimeStamp
structure has a null value.
Remarks
The precision of the OracleTimeStamp
can be lost during the conversion.
The OracleTimeStamp
properties are listed in Table 12-98.
Table 12-98 OracleTimeStamp Properties
Properties | Description |
---|---|
Returns an array of bytes that represents an Oracle |
|
Specifies the day component of an |
|
Indicates whether or not the |
|
Specifies the hour component of an |
|
Specifies the millisecond component of an |
|
Specifies the minute component of an |
|
Specifies the month component of an |
|
Specifies the nanosecond component of an |
|
Specifies the second component of an |
|
Specifies the date and time that is stored in the |
|
Specifies the year component of an |
This property returns an array of bytes that represents an Oracle TIMESTAMP
in Oracle internal format.
Declaration
// C# public byte[] BinData {get;}
Property Value
A byte array that represents an Oracle TIMESTAMP
in an internal format.
Exceptions
OracleNullValueException
- The current instance has a null value.
This property specifies the day component of an OracleTimeStamp.
Declaration
// C# public int Day{get;}
Property Value
A number that represents the day. Range of Day
is (1 to 31).
Exceptions
OracleNullValueException
- The current instance has a null value.
This property indicates whether or not the current instance has a null value.
Declaration
// C# public bool IsNull{get;}
Property Value
Returns true
if the current instance has a null value; otherwise, returns false
.
This property specifies the hour component of an OracleTimeStamp
.
Declaration
// C# public int Hour{get;}
Property Value
A number that represents the hour. Range of hour
is (0 to 23).
Exceptions
OracleNullValueException
- The current instance has a null value.
This property gets the millisecond component of an OracleTimeStamp.
Declaration
// C# public double Millisecond{get;}
Property Value
A number that represents a millisecond. Range of Millisecond
is (0 to 999.999999).
Exceptions
OracleNullValueException
- The current instance has a null value.
This property gets the minute component of an OracleTimeStamp.
Declaration
// C# public int Minute{get;}
Property Value
A number that represent a minute. Range of Minute
is (0 to 59).
Exceptions
OracleNullValueException
- The current instance has a null value.
This property gets the month component of an OracleTimeStamp
.
Declaration
// C# public int Month{get;}
Property Value
A number that represents a month. Range of Month
is (1 to 12).
Exceptions
OracleNullValueException
- The current instance has a null value.
This property gets the nanosecond component of an OracleTimeStamp.
Declaration
// C# public int Nanosecond{get;}
Property Value
A number that represents a nanosecond. Range of Nanosecond
is (0 to 999999999).
Exceptions
OracleNullValueException
- The current instance has a null value.
This property gets the second component of an OracleTimeStamp.
Declaration
// C# public int Second{get;}
Property Value
A number that represents a second. Range of Second
is (0 to 59).
Exceptions
OracleNullValueException
- The current instance has a null value.
This property specifies the date and time that is stored in the OracleTimeStamp
structure.
Declaration
// C# public DateTime Value{get;}
Property Value
A DateTime
.
Exceptions
OracleNullValueException
- The current instance has a null value.
This property gets the year component of an OracleTimeStamp.
Declaration
// C# public int Year{get;}
Property Value
A number that represents a year. The range of Year
is (-4712 to 9999).
Exceptions
OracleNullValueException
- The current instance has a null value.
The OracleTimeStamp
methods are listed in Table 12-99.
Table 12-99 OracleTimeStamp Methods
Methods | Description |
---|---|
Adds the supplied number of days to the current instance |
|
Adds the supplied number of hours to the current instance |
|
Adds the supplied number of milliseconds to the current instance |
|
Adds the supplied number of minutes to the current instance |
|
Adds the supplied number of months to the current instance |
|
Adds the supplied number of nanoseconds to the current instance |
|
Adds the supplied number of seconds to the current instance |
|
Adds the supplied number of years to the current instance |
|
Compares the current |
|
Determines whether or not an object has the same date and time as the current |
|
Returns a hash code for the |
|
Subtracts an |
|
Subtracts |
|
GetType |
Inherited from |
Converts the current |
|
Converts the current |
|
Converts the current |
|
Converts the current |
This method adds the supplied number of days to the current instance.
Declaration
// C#
public OracleTimeStamp AddDays(double days);
Parameters
days
The supplied number of days. Range is (-1,000,000,000 < days
< 1,000,000,000)
Return Value
An OracleTimeStamp
.
Exceptions
ArgumentOutofRangeException
- The argument value is out of the specified range.
OracleNullValueException
- The current instance has a null value.
This method adds the supplied number of hours to the current instance.
Declaration
// C#
public OracleTimeStamp AddHours(double hours);
Parameters
hours
The supplied number of hours. Range is (-24,000,000,000 < hours
< 24,000,000,000).
Return Value
An OracleTimeStamp
.
Exceptions
ArgumentOutofRangeException
- The argument value is out of the specified range.
OracleNullValueException
- The current instance has a null value.
This method adds the supplied number of milliseconds to the current instance.
Declaration
// C#
public OracleTimeStamp AddMilliseconds(double milliseconds);
Parameters
milliseconds
The supplied number of milliseconds. Range is (-8.64 * 1016< milliseconds
< 8.64 * 1016).
Return Value
An OracleTimeStamp
.
Exceptions
ArgumentOutofRangeException
- The argument value is out of the specified range.
OracleNullValueException
- The current instance has a null value.
This method adds the supplied number of minutes to the current instance.
Declaration
// C#
public OracleTimeStamp AddMinutes(double minutes);
Parameters
minutes
The supplied number of minutes. Range is (-1,440,000,000,000 < minutes
< 1,440,000,000,000).
Return Value
An OracleTimeStamp
.
Exceptions
ArgumentOutofRangeException
- The argument value is out of the specified range.
OracleNullValueException
- The current instance has a null value.
This method adds the supplied number of months to the current instance.
Declaration
// C#
public OracleTimeStamp AddMonths(long months);
Parameters
months
The supplied number of months. Range is (-12,000,000,000 < months
< 12,000,000,000).
Return Value
An OracleTimeStamp
.
Exceptions
ArgumentOutofRangeException
- The argument value is out of the specified range.
OracleNullValueException
- The current instance has a null value.
This method adds the supplied number of nanoseconds to the current instance.
Declaration
// C#
public OracleTimeStamp AddNanoseconds(long nanoseconds);
Parameters
nanoseconds
The supplied number of nanoseconds.
Return Value
An OracleTimeStamp
.
Exceptions
OracleNullValueException
- The current instance has a null value.
This method adds the supplied number of seconds to the current instance.
Declaration
// C#
public OracleTimeStamp AddSeconds(double seconds);
Parameters
seconds
The supplied number of seconds. Range is (-8.64 * 1013< seconds
< 8.64 * 1013).
Return Value
An OracleTimeStamp
.
Exceptions
ArgumentOutofRangeException
- The argument value is out of the specified range.
OracleNullValueException
- The current instance has a null value.
This method adds the supplied number of years to the current instance.
Declaration
// C#
public OracleTimeStamp AddYears(int years);
Parameters
years
The supplied number of years. Range is (-999,999,999 <= years
< = 999,999,999)
Return Value
An OracleTimeStamp
.
Exceptions
ArgumentOutofRangeException
- The argument value is out of the specified range.
OracleNullValueException
- The current instance has a null value.
This method compares the current OracleTimeStamp
instance to an object, and returns an integer that represents their relative values.
Declaration
// C#
public int CompareTo(object obj);
Parameters
obj
The object being compared to the current OracleTimeStamp
instance.
Return Value
The method returns a number that is:
Less than zero: if the current OracleTimeStamp
instance value is less than that of obj
.
Zero: if the current OracleTimeStamp
instance and obj
values are equal.
Greater than zero: if the current OracleTimeStamp
instance value is greater than that of obj
.
Implements
IComparable
Exceptions
ArgumentException
- The obj
parameter is not of type OracleTimeStamp
.
Remarks
The following rules apply to the behavior of this method.
The comparison must be between OracleTimeStamp
s. For example, comparing an OracleTimeStamp
instance with an OracleBinary
instance is not allowed. When an OracleTimeStamp
is compared with a different type, an ArgumentException
is thrown.
Any OracleTimeStamp
that has a value is greater than an OracleTimeStamp
that has a null value.
Two OracleTimeStamp
s that contain a null value are equal.
Overrides Object
This method determines whether or not an object has the same date and time as the current OracleTimeStamp
instance.
Declaration
// C#
public override bool Equals(object obj);
Parameters
obj
The object being compared to the current OracleTimeStamp
instance.
Return Value
Returns true
if the obj
is of type OracleTimeStamp
and represents the same date and time; otherwise, returns false
.
Remarks
The following rules apply to the behavior of this method.
Any OracleTimeStamp
that has a value is greater than an OracleTimeStamp
that has a null value.
Two OracleTimeStamp
s that contain a null value are equal.
Overrides Object
This method returns a hash code for the OracleTimeStamp
instance.
Declaration
// C# public override int GetHashCode();
Return Value
A number that represents the hash code.
This method subtracts an OracleTimeStamp
value from the current instance and returns an OracleIntervalDS
that represents the time difference between the supplied OracleTimeStamp
structure and the current instance.
Declaration
// C#
public OracleIntervalDS GetDaysBetween(OracleTimeStamp value1);
Parameters
value1
The OracleTimeStamp
value being subtracted.
Return Value
An OracleIntervalDS
that represents the interval between two OracleTimeStamp
values.
Remarks
If either the current instance or the parameter has a null value, the returned OracleIntervalDS
has a null value.
This method subtracts an OracleTimeStamp
value from the current instance and returns an OracleIntervalYM
that represents the time difference between the OracleTimeStamp
value and the current instance.
Declaration
// C#
public OracleIntervalYM GetYearsBetween(OracleTimeStamp value1);
Parameters
value1
The OracleTimeStamp
value being subtracted.
Return Value
An OracleIntervalYM
that represents the interval between two OracleTimeStamp
values.
Remarks
If either the current instance or the parameter has a null value, the returned OracleIntervalYM
has a null value.
This method converts the current OracleTimeStamp
structure to an OracleDate
structure.
Declaration
// C# public OracleDate ToOracleDate();
Return Value
The returned OracleDate
contains the date and time in the current instance.
Remarks
The precision of the OracleTimeStamp
value can be lost during the conversion.
If the value of the OracleTimeStamp
has a null value, the value of the returned OracleDate
structure has a null value.
This method converts the current OracleTimeStamp
structure to an OracleTimeStampLTZ
structure.
Declaration
// C# public OracleTimeStampLTZ ToOracleTimeStampLTZ();
Return Value
The returned OracleTimeStampLTZ
contains date and time in the current instance.
Remarks
If the value of the current instance has a null value, the value of the returned OracleTimeStampLTZ
structure has a null value.
This method converts the current OracleTimeStamp
structure to an OracleTimeStampTZ
structure.
Declaration
// C# public OracleTimeStampTZ ToOracleTimeStampTZ();
Return Value
The returned OracleTimeStampTZ
contains the date and time from the OracleTimeStamp
and the time zone from the OracleGlobalization.TimeZone
of the thread.
Remarks
If the value of the current instance has a null value, the value of the returned OracleTimeStampTZ
structure has a null value.
See Also:
Overrides Object
This method converts the current OracleTimeStamp
structure to a string.
Declaration
// C# public override string ToString();
Return Value
A string
that represents the same date and time as the current OracleTimeStamp
structure.
Remarks
The returned value is a string representation of an OracleTimeStamp
in the format specified by the OracleGlobalization
.TimeStampFormat
property of the thread.
The names and abbreviations used for months and days are in the language specified by the OracleGlobalization
's DateLanguage
and Calendar
properties of the thread. If any of the thread's globalization properties are set to null or an empty string, the client computer's settings are used.
Example
// C# using System; using Oracle.DataAccess.Types; using Oracle.DataAccess.Client; class ToStringSample { static void Main() { // Set the nls_timestamp_format for the OracleTimeStamp(string) // constructor OracleGlobalization info = OracleGlobalization.GetClientInfo(); info.TimeStampFormat = "DD-MON-YYYY HH:MI:SS.FF AM"; OracleGlobalization.SetThreadInfo(info); // construct OracleTimeStamp from a string using the format specified. OracleTimeStamp ts = new OracleTimeStamp("11-NOV-1999 11:02:33.444 AM"); // Set the nls_timestamp_format for the ToString() method info.TimeStampFormat = "YYYY-MON-DD HH:MI:SS.FF AM"; OracleGlobalization.SetThreadInfo(info); // Prints "1999-NOV-11 11:02:33.444000000 AM" Console.WriteLine(ts.ToString()); } }