Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> Re: Date Conversion
--0__=YwenYsaU8CiDPn9gGpJC5aXN7UKR2h9QrY8ltdx6ajbpgTUyx7lfl08n
Content-type: text/plain; charset=us-ascii
What you see is the number of miliseconds since January 1, 1970 - this is how the dates are stored internally in Java.
All you have to is write small PL/SQL procedure that would take this number
and divide it by 1000 - this would give you the number of seconds since
01/01/1970.
Then you have to divide it by 60 -- number of minutes,
then again by 60 -- hours and
then again by 24 - number of days since 1970.
Not it's a matter of simple math.
Depending on how precise you want to get when storing the date in Oracle database you can choose to either store it up until seconds or in truncated format (don't care about the date, then always use midnight).
Depending on the size of the table, it would be much easier to actually write a 10 line Java program that would do the conversion and update these dates into Oracle database and place them into the regular DATE column vs. PL/SQL code. The reason being is that Java actually will allow you to create a date based on this value that then can be easily stored into the database in the DATE format.
I am not sure why these guys decided to store these dates in Java INTERNAL format -- very inconvenient.
Tell them about java.sql.Date class and that it should be used whenever dealing with database DATE fields.
Val Gamerman
Oracle DBA
To: Multiple recipients of list ORACLE-L <ORACLE-L_at_fatcity.com> cc: (bcc: Val Gamerman/Victoria Financial) From: Jeff Wiegand <jwiegand_at_ancept.com> @ NOTES NET Date: 08/31/2000 04:17:49 PM GMT
Hello List.
We need to convert two columns in a table to date type. Currently, the two
columns are Varchar2. This wouldn't be a problem if there were actual dates
held in the columns. A Java application inserts into the table, and
inserted
in a format such as this:
964473249811
964473412927
964473649881
964473659746
964473882543
964473915782
964473972845
966970660171
Each one of those values represents a date. Is there a way to make sense of
this? A way to convert this to a date value Oracle will recognize. One
developer told me these are long date values (milliseconds since some date
or something).
--0__=YwenYsaU8CiDPn9gGpJC5aXN7UKR2h9QrY8ltdx6ajbpgTUyx7lfl08n
Content-type: text/html;
name="att1.htm"
Content-transfer-encoding: base64
Content-Description: Internet HTML
PCFET0NUWVBFIEhUTUwgUFVCTElDICItLy9XM0MvL0RURCBIVE1MIDMuMi8vRU4iPg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