Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Oracle timestamp to unix timestamp

459495Nov 7 2005 — edited Nov 14 2005
Hi everyone!
I need to convert a values fetched from a db table in a unix timestamp (seconds passed by january first 1970).

The table is like this
create table test(.... ts timestamp not null...);

and the code to define the output variable (for a select statement) is the following, where time is an OCIDateTime variable

OCIDefineByPos(stmth, &defineh, errh, pos, (dvoid *) time, 0, SQLT_ODT,
(dvoid *) 0, (ub2 *) 0, (ub2 *) 0, OCI_DEFAULT);

once I have initialized "time", how can I convert his content to unix timestamp?
And viceversa, how can I put an int value rapresenting a unix timestamp in an OCIDateTime variable, and then insert it correctly inside mt table?
thank you!
GePs
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 12 2005
Added on Nov 7 2005
9 comments
13,784 views