Unable to parse Oracle timestamp in C#

后端 未结 3 1970
执念已碎
执念已碎 2021-01-21 08:49

I have timestamp of Oracle:

string timestamp = \"23-JUN-14 09.39.04.000000000 AM\";

I am not able to parse it into system date time object. I u

3条回答
  •  梦谈多话
    2021-01-21 09:07

    .NET DateTime structure has a precision of tick - 100 nanoseconds - 0.0000001 of second - 7 decimal positions after the point.

    Oracle TimeStamp has a precision of up to nanosecond - 0.000000001 - 9 decimal positions after the point.


    That is why standard DateTime cannot store all possible oracle TimeStamps. And its parsing function simply fail on more precise string representations of TimeStamp.


    So, what could be tried:

    • Format your TimeStamps in query to some format parseable by DataTime(with loss of precision if necessary) - http://docs.oracle.com/cd/B19306_01/server.102/b14200/sql_elements004.htm
    • Or create your own more precise CustomTimeStamp .Net structure and parse to it manually

提交回复
热议问题