retrieve and convert date using pro*c

Posted on 2004-10-26
Last Modified: 2008-02-01
   I have an Oracle table with a single field called 'rundate'. This field contains a date in the format of date. I need to retrieve this using pro*c code and convert it a number(5) value. Any help would be much appreciated.

Question by:dustybryn
    LVL 12

    Accepted Solution

    Hi dustybryn,
    You can do that in Oracle directly. Here's an example of converting an Oracle date into C-style time_t:

    select (effective_date - to_date('19700101','YYYYMMDD')) * 86400 time_t from subscriber

    Whatever the anchor date for your calendar operation is, you can use the same approach. Example: Number of days since 01/01/2000

    select trunc(effective_date - to_date('20000101','YYYYMMDD')) millenium_days from subscriber



    Author Comment

    Thanks for this Stefan, much appreciated

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone. Privacy Policy Terms of Use

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
    Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode ( They will have you believe that Unicode requires you to use…
    Video by: Grant
    The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.
    Video by: Grant
    The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.

    875 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now