Problems getting Oracle TimeStamp fields in .Net

I need to get started with milliseconds in .Net 3.0. The data will be returned from the Oracle database, and if I understand correctly, Oracle can only store dates that use milliseconds as TimeStamp. It seems that the Date type in .Net can handle milliseconds, but when I tried to get timestamps from Oracle stored procedures, I ran into an unpleasant error in the past. Can .NET handle the Oracle timestamp data type or do I need to return it as a VarChar and apply it to a date type?

Thanks,

Dave

+3
source share
2 answers

ODP.NET, Oracle.DataAccess.Types.OracleTimeStamp. Value, System.DateTime.

:

    Private Function GetTimeStamp() As DateTime

        Dim timeStamp As DateTime

        Dim sql As String = "your timestamp query"

        Using conn As OracleConnection = New OracleConnection("your connection string")
            Using command As OracleCommand = New OracleCommand(sql, conn)
                conn.Open()

                Using dataReader As OracleDataReader = command.ExecuteReader(CommandBehavior.CloseConnection)
                    If dataReader.Read() Then
                        timeStamp = dataReader.GetOracleTimeStamp(0).Value
                    End If
                End Using

            End Using
        End Using

        Return timeStamp

    End Function
+3

, .

Oracle Access. , ( ) 1/1/1970. :

/86400 + 25569

format() , .

0

Source: https://habr.com/ru/post/1709326/


All Articles