| Oracle® Data Provider for .NET Developer's Guide 11g Release 2 (11.2.0.3) Part Number E23174-02 |
|
|
PDF · Mobi · ePub |
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.
System.Object
System.ValueType
Oracle.DataAccess.Types.OracleTimeStamp
// ADO.NET 2.0: C#public struct OracleTimeStamp : IComparable, INullable, IXmlSerializable
All public static methods are thread-safe, although instance methods do not guarantee thread safety.
// 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);
}
}
Namespace: Oracle.DataAccess.Types
Assembly: Oracle.DataAccess.dll
ODP.NET Version: ODP.NET for .NET Framework 2.0 or ODP.NET for .NET Framework 4
See Also:
OracleTimeStamp members are listed in the following tables:
OracleTimeStamp constructors are listed in Table 14-87
Table 14-87 OracleTimeStamp Constructors
| Constructor | Description |
|---|---|
|
Instantiates a new instance of |
The OracleTimeStamp static fields are listed in Table 14-88.
Table 14-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 14-89.
Table 14-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 14-90.
Table 14-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 14-91.
Table 14-91 OracleTimeStamp Static Type Conversions
| Operator | Description |
|---|---|
|
Converts an instance value to an |
|
|
Converts an instance value to an |
|
|
Converts an |
The OracleTimeStamp properties are listed in Table 14-92.
Table 14-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 |
The OracleTimeStamp methods are listed in Table 14-93.
Table 14-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.
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.
// C#
public OracleTimeStamp (DateTime dt);
dt
The supplied DateTime value.
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.
// C#
public OracleTimeStamp (string tsStr);
tsStr
A string that represents an Oracle TIMESTAMP.
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.
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.
// 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 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.
// C# public OracleTimeStamp(int year, int month, int day);
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).
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.
// C# public OracleTimeStamp (int year, int month, int day, int hour, int minute, int second);
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).
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.
// C# public OracleTimeStamp(int year, int month, int day, int hour, int minute, int second, double millisecond);
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).
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.
// C# public OracleTimeStamp (int year, int month, int day, int hour, int minute, int second, int nanosecond);
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).
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.
// C#
public OracleTimeStamp (byte[] bytes);
bytes
A byte array that represents an Oracle TIMESTAMP in Oracle internal format.
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 14-94.
Table 14-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.
// 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.
// C# public static readonly OracleTimeStamp MinValue;
This static field represents a null value that can be assigned to an instance of the OracleTimeStamp structure.
// C# public static readonly OracleTimeStamp Null;
The OracleTimeStamp static methods are listed in Table 14-95.
Table 14-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.
// C# public static bool Equals(OracleTimeStamp value1, OracleTimeStamp value2);
value1
The first OracleTimeStamp.
value2
The second OracleTimeStamp.
Returns true if two OracleTimeStamp values are equal; otherwise, returns false.
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 OracleTimeStamps that contain a null value are equal.
This static method determines if the first of two OracleTimeStamp values is greater than the second.
// C# public static bool GreaterThan(OracleTimeStamp value1, OracleTimeStamp value2);
value1
The first OracleTimeStamp.
value2
The second OracleTimeStamp.
Returns true if the first of two OracleTimeStamp values is greater than the second; otherwise, returns false.
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 OracleTimeStamps 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.
// C# public static bool GreaterThanOrEqual(OracleTimeStamp value1, OracleTimeStamp value2);
value1
The first OracleTimeStamp.
value2
The second OracleTimeStamp.
Returns true if the first of two OracleTimeStamp values is greater than or equal to the second; otherwise, returns false.
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 OracleTimeStamps that contain a null value are equal.
This static method determines if the first of two OracleTimeStamp values is less than the second.
// C# public static bool LessThan(OracleTimeStamp value1, OracleTimeStamp value2);
value1
The first OracleTimeStamp.
value2
The second OracleTimeStamp.
Returns true if the first of two OracleTimeStamp values is less than the second. Returns false otherwise.
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 OracleTimeStamps 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.
// C# public static bool LessThanOrEqual(OracleTimeStamp value1, OracleTimeStamp value2);
value1
The first OracleTimeStamp.
value2
The second OracleTimeStamp.
Returns true if the first of two OracleTimeStamp values is less than or equal to the second. Returns false otherwise.
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 OracleTimeStamps that contain a null value are equal.
This static method determines if two OracleTimeStamp values are not equal.
// C# public static bool NotEquals(OracleTimeStamp value1, OracleTimeStamp value2);
value1
The first OracleTimeStamp.
value2
The second OracleTimeStamp.
Returns true if two OracleTimeStamp values are not equal. Returns false otherwise.
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 OracleTimeStamps that contain a null value are equal.
This static method gets an OracleTimeStamp structure that represents the current date and time.
// C# public static OracleTimeStamp GetSysDate();
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.
// C#
public static OracleTimeStamp Parse(string datetime);
datetime
A string that represents an Oracle TIMESTAMP.
An OracleTimeStamp structure.
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.
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.
// 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.
// C# public static OracleTimeStamp SetPrecision(OracleTimeStamp value1, int fracSecPrecision);
value1
The provided OracleTimeStamp object.
fracSecPrecision
The fractional second precision provided. Range of fractional second precision is (0 to 9).
An OracleTimeStamp structure with the specified fractional second precision.
ArgumentOutOfRangeException - fracSecPrecision is out of the specified range.
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().
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 14-96.
Table 14-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.
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.
// C# public static operator + (OracleTimeStamp value1, OracleIntervalDS value2);
value1
An OracleTimeStamp.
value2
An OracleIntervalDS.
An OracleTimeStamp.
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.
// C# public static operator + (OracleTimeStamp value1, OracleIntervalYM value2);
value1
An OracleTimeStamp.
value2
An OracleIntervalYM.
An OracleTimeStamp.
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.
// C# public static operator + (OracleTimeStamp value1, TimeSpan value2);
value1
An OracleTimeStamp.
value2
A TimeSpan.
An OracleTimeStamp.
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.
// C# public static bool operator == (OracleTimeStamp value1, OracleTimeStamp value2);
value1
The first OracleTimeStamp.
value2
The second OracleTimeStamp.
Returns true if they are the same; otherwise, returns false.
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 OracleTimeStamps that contain a null value are equal.
This static operator determines if the first of two OracleTimeStamp values is greater than the second.
// C# public static bool operator > (OracleTimeStamp value1, OracleTimeStamp value2);
value1
The first OracleTimeStamp.
value2
The second OracleTimeStamp.
Returns true if the first OracleTimeStamp value is greater than the second; otherwise, returns false.
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 OracleTimeStamps 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.
// C# public static bool operator >= (OracleTimeStamp value1, OracleTimeStamp value2);
value1
The first OracleTimeStamp.
value2
The second OracleTimeStamp.
Returns true if the first OracleTimeStamp is greater than or equal to the second; otherwise returns false.
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 OracleTimeStamps that contain a null value are equal.
This static operator determines if two OracleTimeStamp values are not equal.
// C# public static bool operator != (OracleTimeStamp value1, OracleTimeStamp value2);
value1
The first OracleTimeStamp.
value2
The second OracleTimeStamp.
Returns true if two OracleTimeStamp values are not equal; otherwise, returns false.
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 OracleTimeStamps that contain a null value are equal.
This static operator determines if the first of two OracleTimeStamp values is less than the second.
// C# public static bool operator < (OracleTimeStamp value1, OracleTimeStamp value2);
value1
The first OracleTimeStamp.
value2
The second OracleTimeStamp.
Returns true if the first OracleTimeStamp is less than the second; otherwise, returns false.
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 OracleTimeStamps 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.
// C# public static bool operator <= (OracleTimeStamp value1, OracleTimeStamp value2);
value1
The first OracleTimeStamp.
value2
The second OracleTimeStamp.
Returns true if the first OracleTimeStamp is less than or equal to the second; otherwise, returns false.
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 OracleTimeStamps that contain a null value are equal.
operator- subtracts the supplied value, from the supplied OracleTimeStamp value, and returns a new OracleTimeStamp structure.
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.
// C# public static operator - (OracleTimeStamp value1, OracleIntervalDS value2);
value1
An OracleTimeStamp.
value2
An OracleIntervalDS instance.
An OracleTimeStamp structure.
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.
// C# public static operator - (OracleTimeStamp value1, OracleIntervalYM value2);
value1
An OracleTimeStamp.
value2
An OracleIntervalYM instance.
An OracleTimeStamp structure.
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.
// C# public static operator - (OracleTimeStamp value1, TimeSpan value2);
value1
An OracleTimeStamp.
value2
A TimeSpan instance.
An OracleTimeStamp structure.
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 14-97.
Table 14-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
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.
// C#
public static explicit operator OracleTimeStamp(OracleTimeStampLTZ value1);
value1
An OracleTimeStampLTZ instance.
The returned OracleTimeStamp contains the date and time of the OracleTimeStampLTZ structure.
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.
// C#
public static explicit operator OracleTimeStamp(OracleTimeStampTZ value1);
value1
An OracleTimeStampTZ instance.
The returned OracleTimeStamp contains the date and time information from value1, but the time zone information from value1 is truncated.
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.
// C#
public static explicit operator OracleTimeStamp(string tsStr);
tsStr
A string representation of an Oracle TIMESTAMP.
An OracleTimeStamp.
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.
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.
// 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 Reference for further information on datetime format elements
This static type conversion operator converts a value to an OracleTimeStamp structure.
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.
// C#
public static implicit operator OracleTimeStamp (OracleDate value1);
value1
An OracleDate instance.
An OracleTimeStamp structure that contains the date and time of the OracleDate structure, value1.
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.
// C#
public static implicit operator OracleTimeStamp(DateTime value);
value
A DateTime instance.
An OracleTimeStamp structure.
This static type conversion operator converts an OracleTimeStamp value to a DateTime structure.
// C#
public static explicit operator DateTime(OracleTimeStamp value1);
value1
An OracleTimeStamp instance.
A DateTime containing the date and time in the current instance.
OracleNullValueException - The OracleTimeStamp structure has a null value.
The precision of the OracleTimeStamp can be lost during the conversion.
The OracleTimeStamp properties are listed in Table 14-98.
Table 14-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.
// C#
public byte[] BinData {get;}
A byte array that represents an Oracle TIMESTAMP in an internal format.
OracleNullValueException - The current instance has a null value.
This property specifies the day component of an OracleTimeStamp.
// C#
public int Day{get;}
A number that represents the day. Range of Day is (1 to 31).
OracleNullValueException - The current instance has a null value.
This property indicates whether or not the current instance has a null value.
// C#
public bool IsNull{get;}
Returns true if the current instance has a null value; otherwise, returns false.
This property specifies the hour component of an OracleTimeStamp.
// C#
public int Hour{get;}
A number that represents the hour. Range of hour is (0 to 23).
OracleNullValueException - The current instance has a null value.
This property gets the millisecond component of an OracleTimeStamp.
// C#
public double Millisecond{get;}
A number that represents a millisecond. Range of Millisecond is (0 to 999.999999).
OracleNullValueException - The current instance has a null value.
This property gets the minute component of an OracleTimeStamp.
// C#
public int Minute{get;}
A number that represent a minute. Range of Minute is (0 to 59).
OracleNullValueException - The current instance has a null value.
This property gets the month component of an OracleTimeStamp.
// C#
public int Month{get;}
A number that represents a month. Range of Month is (1 to 12).
OracleNullValueException - The current instance has a null value.
This property gets the nanosecond component of an OracleTimeStamp.
// C#
public int Nanosecond{get;}
A number that represents a nanosecond. Range of Nanosecond is (0 to 999999999).
OracleNullValueException - The current instance has a null value.
This property gets the second component of an OracleTimeStamp.
// C#
public int Second{get;}
A number that represents a second. Range of Second is (0 to 59).
OracleNullValueException - The current instance has a null value.
This property specifies the date and time that is stored in the OracleTimeStamp structure.
// C#
public DateTime Value{get;}
A DateTime.
OracleNullValueException - The current instance has a null value.
This property gets the year component of an OracleTimeStamp.
// C#
public int Year{get;}
A number that represents a year. The range of Year is (-4712 to 9999).
OracleNullValueException - The current instance has a null value.
The OracleTimeStamp methods are listed in Table 14-99.
Table 14-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.
// C#
public OracleTimeStamp AddDays(double days);
days
The supplied number of days. Range is (-1,000,000,000 < days < 1,000,000,000)
An OracleTimeStamp.
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.
// C#
public OracleTimeStamp AddHours(double hours);
hours
The supplied number of hours. Range is (-24,000,000,000 < hours < 24,000,000,000).
An OracleTimeStamp.
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.
// C#
public OracleTimeStamp AddMilliseconds(double milliseconds);
milliseconds
The supplied number of milliseconds. Range is (-8.64 * 1016< milliseconds < 8.64 * 1016).
An OracleTimeStamp.
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.
// C#
public OracleTimeStamp AddMinutes(double minutes);
minutes
The supplied number of minutes. Range is (-1,440,000,000,000 < minutes < 1,440,000,000,000).
An OracleTimeStamp.
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.
// C#
public OracleTimeStamp AddMonths(long months);
months
The supplied number of months. Range is (-12,000,000,000 < months < 12,000,000,000).
An OracleTimeStamp.
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.
// C#
public OracleTimeStamp AddNanoseconds(long nanoseconds);
nanoseconds
The supplied number of nanoseconds.
An OracleTimeStamp.
OracleNullValueException - The current instance has a null value.
This method adds the supplied number of seconds to the current instance.
// C#
public OracleTimeStamp AddSeconds(double seconds);
seconds
The supplied number of seconds. Range is (-8.64 * 1013< seconds < 8.64 * 1013).
An OracleTimeStamp.
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.
// C#
public OracleTimeStamp AddYears(int years);
years
The supplied number of years. Range is (-999,999,999 <= years < = 999,999,999)
An OracleTimeStamp.
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.
// C#
public int CompareTo(object obj);
obj
The object being compared to the current OracleTimeStamp instance.
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.
IComparable
ArgumentException - The obj parameter is not of type OracleTimeStamp.
The following rules apply to the behavior of this method.
The comparison must be between OracleTimeStamps. 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 OracleTimeStamps 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.
// C#
public override bool Equals(object obj);
obj
The object being compared to the current OracleTimeStamp instance.
Returns true if the obj is of type OracleTimeStamp and represents the same date and time; otherwise, returns false.
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 OracleTimeStamps that contain a null value are equal.
Overrides Object
This method returns a hash code for the OracleTimeStamp instance.
// C# public override int GetHashCode();
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.
// C#
public OracleIntervalDS GetDaysBetween(OracleTimeStamp value1);
value1
The OracleTimeStamp value being subtracted.
An OracleIntervalDS that represents the interval between two OracleTimeStamp values.
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.
// C#
public OracleIntervalYM GetYearsBetween(OracleTimeStamp value1);
value1
The OracleTimeStamp value being subtracted.
An OracleIntervalYM that represents the interval between two OracleTimeStamp values.
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.
// C# public OracleDate ToOracleDate();
The returned OracleDate contains the date and time in the current instance.
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.
// C# public OracleTimeStampLTZ ToOracleTimeStampLTZ();
The returned OracleTimeStampLTZ contains date and time in the current instance.
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.
// C# public OracleTimeStampTZ ToOracleTimeStampTZ();
The returned OracleTimeStampTZ contains the date and time from the OracleTimeStamp and the time zone from the OracleGlobalization.TimeZone of the thread.
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.
// C# public override string ToString();
A string that represents the same date and time as the current OracleTimeStamp structure.
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.
// 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());
}
}