rtfm / SQL / Oracle Timestamps / src/sample.sql

/* all of these assume that:
 * 0) the libutl library compiled Ok and works
 * 1) You successfully added the library to oracle [see the makefile]
 *    and helper program
 * 2) The utl package as supplied by me works
 * 3) You managed to add the utl package to oracle
 * 4) The utl package is available to you, by that name, when you are logged in
 *    to Oracle, and you have execute permission on it

/* get the current time_t value, ie seconds since [1970/01/01 00:00:00 UTC] */
select utl.time_t from dual

/* convert a date to a time_t value: */	
select utl.time_t(to_date('2001/04/01 02:46:12', utl.date_fmt)) from dual

/* get the current date/time value in the UTC zone */
select utl.date_t from dual

/* convert a time_t to an oracle date value */
select utl.date_t(986089842) from dual

Valid HTML 4.01! Valid CSS! Any Browser Debian Pepperfish