Date of the Oracle in unix timestamp

Hello..

1. What is the command to convert oracle date to unix timestamp?
2. What is the command to convert oracle unix timestamp date?

It's my request of conversion, but when I converted from date oracle on another server time become a late hour. Why this happened?... y at - it no problem on the configuration of my sessiontimezone or dbtimezone?

create or replace FUNCTION oracle_to_unix
(
in_date IN DATE)
RETURN NUMBER
IS
BEGIN
RETURN (in_date-TO_DATE('19700101','yyyymmdd')) * 86400 - TO_NUMBER (SUBSTR (TZ_OFFSET (sessiontimezone), 1, 3)) * 3600;
END;


Please help me...

Thank you
Balleur

Hello!

If I subtracted something and then add the same then I should get the same result.

I tried like this

SQL> select sessiontimezone from dual;

SESSIONTIMEZONE
---------------------------------------------------------------------------
+01:00

SQL> select dbtimezone from dual;

DBTIME
------
+02:00

SQL> select (to_date('14.03.2010 08:16:22','dd.mm.yyyy HH24:mi:ss')
  2        - to_date('01.01.1970 00:00:00','dd.mm.yyyy HH24:mi:ss')) * 24 * 60 * 60
  3        - TO_NUMBER(SUBSTR(TZ_OFFSET(sessiontimezone),1,3))*3600 utim
  4    from dual
  5  /

      UTIM
----------
1268550982

SQL> select to_char(to_date('01.01.1970 00:00:00','dd.mm.yyyy HH24:mi:ss') +
  2  (1268550982+TO_NUMBER(SUBSTR(TZ_OFFSET(sessiontimezone),1,3))*3600) / 24 / 60 / 60,
  3  'DD.MM.YYYY HH24:MI:SS')  from dual
  4  /

TO_CHAR(TO_DATE('01
-------------------
14.03.2010 08:16:22

SQL> 

and he seems allright for me.
Check sessiontimezone sessions on both servers. This calculation depends only on sessiontimezones.

T

Tags: Database

Similar Questions

  • Essbase Studio impossible to 'Examining the sample data' in the Oracle DB Data Source

    E.M.P. version 11.1.2.3.500

    Oracle DB 11.2.0.4

    on Windows 2008R2

    I created a user DB ESSTBC with the following user privileges

    CREATE SESSION, CREATE TABLE, CREATE TRIGGER, CREATE TYPE, CREATE VIEW

    This is my first attempt on the Essbase Studio, so I executed the following scripts as the user ESSTBC to create the TBC tables and load the data

    tbc_create_oracle. SQL

    tbc_sampledata. SQL

    I am able to connect with ESSTBC and select the tables all loaded and made sure the data is loaded correctly

    Then in the Studio of Essbase, I created a data source, which I can list all the tables in the schema ESSTBC in 'Data Source Navigator'. I also managed to create a Minischema by joining the tables SALES, SCENARIO, and MEASURES.

    However, in "Data Source Navigator" when I select "SCENARIO", right click and select "View Sample Data", I am able to pull data from the table. that is the table with all the names of columns grid but no data. No error messages were shown in "Messages to the Console.

    Back to Developer SQL and connect the same DB as ESSTBC, I have no problem do a "SELECT * SCRIPT;" and recover all the data of the table without a problem.

    I proceed creating dimensions elements then a hierarchy of "SCENARIO". But again when I try to get a glimpse of the hierarchy has got an empty tree. Apparently, there's something wrong,

    No matter what mark on what I missed?

    Thank you very much.

    Problem solved. The cause being my stupidity ruin a access DB. I can see examples of data without changing anything in Essbase Studio after you change the DB user rights.

  • load data to the oracle database...

    Dear Sir

    I use to load data to oracle database .is there other methods to load bulk data to the database sql badr...

    Discover the outer table in Oracle Utilities

  • Record great shape data in the Oracle database

    Hi all

    I have a question as to how we store a large xml for example more than 10000 bytes in the oracle database. I tried to use varchar, but the length is limited to only 4000 bytes. Could someone let me know how to achieve this.

    Basically what I'm doing is in adobe livecycle workflow I will get the user entered data in the form as formData (xml) variable and I want to keep the same for any future reference. I need to use the same data to fill the form again in the future.

    Thanks in advance.

    Shekhar,

    I had handy MySQL, so I did it using that and attached here is a sample. For Oracle, this is mission for you as well as recovery.

    -Wasil

  • Load of LKM for data in the Oracle database

    My source and target are Oracle DB. Source table is to have 1 m + data. I'm looking for LKM that use Oracle Bulk insert utility to load this data into the target table. But I can't find such a for Oracle is database MSSQL (LKM SQL for MSSQL (Bulk)). Please tell me if there is no such LKM in the case of targets Oracle DB.

    Yes. There are.
    I think you missed this one: LKM Oracle for Oracle (DBLINK) .xml

  • Export data from the Oracle Test Manager test

    Hello

    I created a few test (req.s, tests etc.) data in my OTM. Suppose if iam resettlement OATS, how can I get the test data in the new OTM. Can I export these test data to a CSV (windows) so that I can use in important in OTM.
    Can someone help me in this topic?

    Alex, can you please?

    Thank you
    Sandeep.

    Sandeep

    I see, well, you could do a report and export all the test cases, but I think it will be a lot of your time and you would lose another users, attachments, custom projects etc. fields...

    If you need to re - install the database, the best thing to do is a back up and restore, I assume that you use the database default installed (Oracle XE), here are the instructions on how to do a back up and restore:

    http://www.Oracle.com/technology/software/products/database/XE/files/install.102/b25144/TOC.htm#BABJCFBD

    Concerning

    Alex

  • Create the flat file data from the oracle table

    d_adp_num char (10)
    d_schd_date tank (8)
    d_sched_code tank (25)
    d_pay_code char (50)
    d_mil_start char (4)
    d_mil_end char (4)
    d_duration char (5)
    d_site_code char (4)
    d_dept_id tank (6)

    Select payroll_id,
    schedule_date,
    reason_code, (sched_code)
    reason_code, (pay_code)
    start_time,
    end_time,
    total_hours,
    site_code,
    department_id
    of dept_staff
    where schedule_date between (sysdate + 1) and (sysdate + 90)


    loading data for the date range instead.
    sched_code - if 'Unavailable' reason_code = 'OD' and 'THE '.

    pay_code - "Berevevement BD" If reason_code = "BD".
    "UP PTO without reasonable excuse" If reason_code = 'UP '.
    "RG" If reason_code = "SH".
    "PTO" If reason_code = "GO".
    Here are some...

    start_time and end_time - convert military time
    based on start_ampm and end_ampm

    On this basis, I need help to create a flat file. Sewing of the flat and data file in dept_staff sample

    If site_code is there so no need to get department_id (see the sample flat file)
    ------------------------------------

    examples of data to flat file

    ZZW002324006072012 PTO
    0800160008.00
    ZZW002428106072012 RG
    1015174507.50HM34
    ZZW002391606072012 RG
    1100193008.50
    ZZW002430406072012 RG
    1100193008.50 130000
    ----------------------------

    dept_staff table data

    REASON_CODE_1 PAYROLL_ID SCHEDULE_DATE REASON_CODE START_TIME, END_TIME START_AMPM END_AMPM TOTAL_HOURS SITE_CODE DEPARTMENT_ID
    ZZW0024468 08/06/2012 HS HS 730 HAS 400 850 12 P
    ZZW0000199 08/06/2012 HS HS 730 HAS 400 850 14 P
    ZZW0023551 08/06/2012 SH SH 1145 A 930 975 GH08 95 P
    ZZW0024460 08/06/2012 SH SH 515 HAS 330 P 1025 GH08 95
    ZZW0023787 08/06/2012 SH SH 630 HAS 300 850 24 P
    ZZW0024595 08/06/2012 TR TR 730 HAS 400 850 90 P
    ZZW0023516 08/06/2012 OD OD 800 HAS 400 800 95 P
    ZZW0023784 08/06/2012 OD OD 800 HAS 400 800 5 P
    ZZW0024445 08/06/2012 SH SH 1145 A GH08 930 975 5 P
    ZZW0024525 08/06/2012 OD OD 800 HAS 400 800 23 P
    ZZW0024592 08/06/2012 TR TR 730 HAS 400 850 5 P
    ZZW0024509 08/06/2012 SH SH 95 MK21 830 HAS 330 P 700

    ZZW0023916 06/14/2012 SH SH 1100 A 850 27 730 P

    How to ask questions
    SQL and PL/SQL FAQ

    UTL_FILE allows to write the OS file

  • date of the Oracle of the chain

    I have three numbers stored in three different variable and want to join each of them to make a date to a string, although kindly help me with this.

    Published by: AMaster Sep 6, 2012 04:12

    Example:

    SQL> ed
    Wrote file afiedt.buf
    
      1  declare
      2    v_day varchar2(2) := '17';
      3    v_month varchar2(2) := '08';
      4    v_year varchar2(4) := '2012';
      5    v_dt   date;
      6  begin
      7    v_dt := to_date(v_day||v_month||v_year,'DDMMYYYY');
      8* end;
    SQL> /
    
    PL/SQL procedure successfully completed.
    

    It takes 3 channels varchar represents the known parts of a date, assembles them together and turns this chain resulting in a data type DATE by specifying the correct format mask.

    If you want something different, we will need more information.

  • dates of the Oracle

    I have a scenario like below


    Need to compress files and also to preserve if ID moves back between two Cd


    -Table Script _
    create table test_1 (key_id varchar (25), varchar2 (25) cd, strt_dt date, end_dt date);

    -Sample data-

    Insert into TEST_1 (KEY_ID, CD, STRT_DT, END_DT) values ('AAA', ' 13224', to_date (17 June 02 00:00:00 ',' DD-MON-RR HH24:MI:SS'), to_date (April 13 04 00:00:00 ',' DD-MON-RR HH24:MI:SS'));))

    Insert into TEST_1 (KEY_ID, CD, STRT_DT, END_DT) values ('AAA', ' 13224', to_date (14 April 04 00:00:00 ',' DD-MON-RR HH24:MI:SS'), to_date (4 April 05 00:00:00 ',' DD-MON-RR HH24:MI:SS'));))

    Insert into TEST_1 (KEY_ID, CD, STRT_DT, END_DT) values ('AAA', ' 13224', to_date (5 April 05 00:00:00 ',' DD-MON-RR HH24:MI:SS'), to_date (31 October 05 00:00:00 ',' DD-MON-RR HH24:MI:SS'));))

    Insert into TEST_1 (KEY_ID, CD, STRT_DT, END_DT) values ('AAA', ' 13205', to_date (1 November 05 00:00:00 ',' DD-MON-RR HH24:MI:SS'), to_date (26 December 05 00:00:00 ',' DD-MON-RR HH24:MI:SS'));))

    Insert into TEST_1 (KEY_ID, CD, STRT_DT, END_DT) values ('AAA', ' 13205', to_date (27 December 05 00:00:00 ',' DD-MON-RR HH24:MI:SS'), to_date (2 January 06 00:00:00 ',' DD-MON-RR HH24:MI:SS'));))

    Insert into TEST_1 (KEY_ID, CD, STRT_DT, END_DT) values ('AAA', ' 13205', to_date (3 January 06 00:00:00 ',' DD-MON-RR HH24:MI:SS'), to_date (22 May 06 00:00:00 ',' DD-MON-RR HH24:MI:SS'));))

    Insert into TEST_1 (KEY_ID, CD, STRT_DT, END_DT) values ('AAA', ' 13205', to_date (23 May 06 00:00:00 ',' DD-MON-RR HH24:MI:SS'), to_date (11-SEP-06 00:00:00 ',' DD-MON-RR HH24:MI:SS'));))

    Insert into TEST_1 (KEY_ID, CD, STRT_DT, END_DT) values ('AAA', ' 13205', to_date (12-SEP-06 00:00:00 ',' DD-MON-RR HH24:MI:SS'), to_date (18 June 07 00:00:00 ',' DD-MON-RR HH24:MI:SS'));))

    Insert into TEST_1 (KEY_ID, CD, STRT_DT, END_DT) values ('AAA', ' 13205', to_date (19 June 07 00:00:00 ',' DD-MON-RR HH24:MI:SS'), to_date (2 July 07 00:00:00 ',' DD-MON-RR HH24:MI:SS'));))

    Insert into TEST_1 (KEY_ID, CD, STRT_DT, END_DT) values ('AAA', ' 13205', to_date (3 July 07 00:00:00 ',' DD-MON-RR HH24:MI:SS'), to_date (20 August 07 00:00:00 ',' DD-MON-RR HH24:MI:SS'));))

    Insert into TEST_1 (KEY_ID, CD, STRT_DT, END_DT) values ('AAA', ' 13205', to_date (21 August 07 00:00:00 ',' DD-MON-RR HH24:MI:SS'), to_date (15 October 07 00:00:00 ',' DD-MON-RR HH24:MI:SS'));))

    Insert into TEST_1 (KEY_ID, CD, STRT_DT, END_DT) values ('AAA', ' 13224', to_date (16 October 07 00:00:00 ',' DD-MON-RR HH24:MI:SS'), to_date (11 February 08 00:00:00 ',' DD-MON-RR HH24:MI:SS'));))

    Insert into TEST_1 (KEY_ID, CD, STRT_DT, END_DT) values ('AAA', ' 13205', to_date (12 February 08 00:00:00 ',' DD-MON-RR HH24:MI:SS'), to_date (31 March 08 00:00:00 ',' DD-MON-RR HH24:MI:SS'));))

    Insert into TEST_1 (KEY_ID, CD, STRT_DT, END_DT) values ('AAA', ' 13205', to_date (1 April 08 00:00:00 ',' DD-MON-RR HH24:MI:SS'), to_date (14 April 08 00:00:00 ',' DD-MON-RR HH24:MI:SS'));))

    Insert into TEST_1 (KEY_ID, CD, STRT_DT, END_DT) values ('AAA', ' 13205', to_date (15 April 08 00:00:00 ',' DD-MON-RR HH24:MI:SS'), to_date (9 June 08 00:00:00 ',' DD-MON-RR HH24:MI:SS'));))

    COMMIT;

    Desired output:

    AAA 13224 17 JUNE 02 00:00:00 OCTOBER 31 05 00:00:00

    AAA 13205 1 NOVEMBER 05 00:00:00 15 OCTOBER 07 00:00:00

    AAA 13224 16 OCTOBER 07 00:00:00 11 FEBRUARY 08 00:00:00

    AAA 13205 12 FEBRUARY 08 00:00:00 JUNE 9 08 00:00:00

    I am currently using this code but its not keeping do not.

    SELECT ID, min (strt_dt) strt_dt, max end_dt, cd (end_dt)

    de)

    SELECT ID, cd, strt_dt, end_dt, grp,

    Max (GRP) on grp_max (key_id partition, cd command by strt_dt)

    (select rt.key_id, rt.cd, rt.strt_dt, rt.end_dt,

    case

    When (lag (rt.end_dt) over (partition by rt.key_id order, rt.strt_dt rt.cd) <>rt.strt_dt - 1).

    then row_number() over (partition by rt.key_id order, rt.cd of rt.strt_dt)

    end grp

    test_1 RT

    - and rt.end_dt > 20 - JUL - 12 00:00:00 '

    -Order of rt.key_id, rt.strt_dt, rt.end_dt

    Group of)) by key_id, cd command by key_id, strt_dt;

    can someone help me get my desired result.

    SELECT ID,

    CD,

    MIN (strt_dt),

    Max (end_dt)

    Of

    (SELECT ID,

    CD,

    strt_dt,

    end_dt,

    ROWNUM - ROW_NUMBER () OVER (PARTITION BY cd ORDER BY strt_dt) AS grp

    OF test_1

    )

    GROUP BY key_id,

    CD,

    GRP


    Reverence: Frank Kulash

  • Conversion problem of oracle.jbo.domain.Date in java.util.Calendar and oracle.jbo.domain.Timestamp to oracle.jbo.domain.Date

    Hello world

    Work with dates has been harder than I thought! Please take a look at the code; everything compiles, but it fails because I'm not cast properly. Any help would be appreciated.

    Imports are:

    import java.sql.SQLException;

    to import java.text.ParseException;

    import impossible;

    import java.util.Calendar;

    Import oracle.jbo.domain.Date;

    Import oracle.jbo.domain.Timestamp;

    Here is the method:

    public static Date (String sDate, int day, nextDay

    SimpleDateFormat String) {}

    Date result = null;

    java.util.Date date;

    If (sDate! = null) {}

    try {}

    System.out.println ("Try...");

    Calendar calendar = Calendar.GetInstance ();

    SimpleDateFormat dateFormat =

    new SimpleDateFormat (simpleDateFormat);

    calendar.setTime (dateFormat.parse (sDate));

    Calendar.Set (Calendar.DAY_OF_WEEK, date); day = Calendar.SUNDAY

    Calendar.Set (Calendar.HOUR_OF_DAY, 0);

    Calendar.Set (Calendar.MINUTE, 0);

    Calendar.Set (Calendar.SECOND, 0);

    Calendar.Add (Calendar.DATE, 7);

    dateFormat.format (calendar.getTime ());

    try {}

    System.out.println ("try (inside)... ») ;

    "System.out.println (" new Timestamp (calendar.getTime () .getTime ()) "):" +.

    new Timestamp (calendar.getTime () .getTime ()));

    result = new Date (Timestamp (calendar.getTime () .getTime ())) new; Code does not work here.

    return the result;

    } catch (SQLException e) {}

    System.out.println ("catch (SQLException e)... ») ;

    e.printStackTrace ();

    }

    Returns a null value.

    } catch (ParseException exception) e {}

    System.out.println ("catch exception e ParseException... ») ;

    e.printStackTrace ();

    }

    Returns a null value.

    }

    Returns a null value.

    }

    Here is the result:

    try...

    Try (inside)...

    new Timestamp (calendar.getTime () .getTime ())): 2013-12-29 00:00:00.0

    catch (SQLException e)...

    java.sql.SQLException: failed initialization

    to oracle.sql.DATE. < init > (DATE.java:237)

    to oracle.jbo.domain.Date. < init > (Date.java:378)

    James

    try to convert timestamp to jbo.date as

    java.sql.Timestamp datetime =newjava.sql.Timestamp(System.currentTimeMillis());

    oracle.jbo.domain.Date daTime =new  oracle.jbo.domain.Date(datetime);

  • Cannot use the native sequence of database to insert data through the DbAdapter

    Hello

    I use Oracle Fusion Middleware 12.1.3 (selection of pre-designed developer programs for Oracle VM VirtualBox VMs |) Oracle Technology Network). I'm trying to insert data into the Oracle database coming with the device via a DbAdapter. I want to use the native Oracle sequences for primary keys and have configured appropriatelly the DbAdapter. But in execution, I get the following exception:

    Caused by: java.sql.SQLIntegrityConstraintViolationException: ORA-01400: cannot insert NULL into ('SCOTT'. "ORDERS '." (' ' ID ')

    If I configure the such DbAdapter that do not use sequences, I get the same exception. I'm missing here?

    Kind regards

    Nicolas

    Reading more carefully the exception, in the log file of the server, not just the display of messages in the console of the em, I could note that the ConnectionFactory configured on the outgoing Dbadapter connection used to access the database was incorrect. He was using JavaDb instead of Oracle that I made a mistake of copying and pasting. Correction of this error has resolved the problem.

  • Data migration from Oracle to SQL Server

    Hello

    I have the Oracle database in one or several table, I also blob data, i.e. images are stored, now I want to move that data to the sql server database, which is the best way to do this?

    I would like to test for a migration of the table that contains the image data in the Oracle database and invade the SQL Server table.

    How to test for an Oracle table data to SQL Server migration?

    But the first thing I want to confirm is that if the Image from Oracle DB to SQL Server DB data are possible? is there something must be supported during the migration?

    Thanks in advance.

    Kind regards

    Vishal

    Published by: 968331 on October 31, 2012 02:31

    I think that it is supported. The equivalent data type in sql server is IMAGE/varbinary (max)

    See the bottom of the article for the mapping of data types:

    http://weblogs.sqlteam.com/jamesw/archive/2010/07/28/datatypes-translation-between-Oracle-and-SQL-Server-part-1.aspx

  • How to store the captured data in the csv file

    Here's the sceanario

    I was able to capture data from the oracle forms and store it in variables.
    now, I want to store the same data in the csv file and save this csv file.
    quick reply is appreciated.

    Ok. This is what my, admittedly simple, code performs above: var_orderid col1 and col2 in var_quantity.

    See you soon,.
    Jamie

  • How did the type of data stored in oracle timestamp

    I want to know how the timestamp is stored in the oracle database.

    If the data type of a colume's timestamp, the number of bytes is busy?

    What is the principle?

    Thank you.

    Mark - it's a DATE, not a TIMESTAMP

    SQL > create table test (a date, timestamp, b);

    Table created.

    SQL > insert into values test (sysdate, systimestamp);

    1 line of creation.

    SQL > select dump (a) test;

    DUMP (A)

    ------------------------------------------------------------------------

    Typ = Len 12 = 7: 120,115,1,14,17,60,3

    SQL > select dump (b) of the test;

    DUMP (B)

    ------------------------------------------------------------------------

    Typ = 180 Len = 11: 120,115,1,14,17,60,3,17,103,145,0

  • UNIX timestamp to date

    Hello

    I use developer SQL to query an oracle 8 database and
    I need to convert a timestamp unix in a time format date - YYYYMMDD HH24:MI:SS

    I am currently using
    , to_date (19700101' 00:00: 01 ',' YYYYMMDD HH24:MI:SS') + sh.order_date / 86400

    but it returns just the date in the format DD-MMM-AA

    If you want a DATE to look a certain way, use TO_CHAR

    to_char (
       to_date('19700101 00:00:01','YYYYMMDD HH24:MI:SS')+sh.order_date/86400
    , 'YYYYMMDD HH24:MI:SS')
    

Maybe you are looking for

  • Satellite Pro A200/PSAE7 - turn volume change without end, not smooth Volume control

    Hello On my newly purchased Pro A200/PSAE7 control (hardware) volume - front, as soon as speaker - turns without end and when you use the volume does not change "smooth" - more "brutal". For this reason, there is no possible to 'fine tuning '. Q: is

  • Need driver sound WXP for Satellite A300D

    Hello! I have laptop Satellite A300D - 14 kI had to install Windows XP Pro.I have problems with the audio drivers and modem. I am receiveing an error message: instalation of driver failed. Could not find the device support for this driver. I try with

  • I can't install the second disk sata hard

    I have a problem when install the second disk sata hardI bought a new one 500 GB and I installed windows xp sp3and it works well I plugged in SATA 0 portWhen I want to install a second sata hard disk 320 on sata 1and it has an important data, windows

  • How "manually" Update Xperia Sola 6.0.B.3.184 and/or debrand (other firmwares to come)

    How "manually" Update Xperia Sola MT27i 6.0.B.1.654 & and/or debrand (other firmwares to come) Xperia Sola PTCRB HW Version SW version Type of query Date certified A 6.0.B.1.576 ECO May 17, 2012 A 6.0.B.1.536 ECO 23 April 2012 A 6.0.B.1.565 ECO 23 Ap

  • For the Adobe Reader distribution agreement

    Hi allIt's Adobe Reader is free to use in a society with 70 users when you made a distribution agreement?Thank you in advance for taking your time and answer this question.