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')

Tags: Database

Similar Questions

  • Convert unix timestamp to date after the change to daylight saving time

    Hello

    in one of the products, we use internal Scheduler stores dates (and times) in a format Unix, which is seconds since January 1, 1970. We used this SQL to extract the effective date:

    To_char (t.next_fire_time /(24*60*60*1000) + to_date('19700101020000','yyyymmddhh24miss'), 'yyyymmddhh24miss')

    Everything worked well until that time has changed this weekend from UTC + 2 to UTC + 1 (we are located in Eastern Europe). Since then, the above query returns an hour later than planned.

    I.e. of timestamp * 1320067800000 * is returned as * 20111031153000 * even thought is correct (and the actual time, the event was planned) * October 31, 11 PM 02.30.16.000000 *.

    I found queries like this on various forums and nobody seems to care of DST. Is this a configuration problem in the DB or is this a bug in our code?

    I tried selecting the SESSIONTIMEZONE and the DBTIMEZONE and both were + 1.

    Any help appreciated.

    Your problem is coded hard 2 hours shift:

    TO_DATE (19700101'020000', 'yyyymmddhh24miss')

    You need to calculate the current offset to adapt it to the current situation of DST:

    with sample_table as (
                          select date '1970-01-01' + 1320067800000 / 1000 / 3600 / 24 dt_utc from dual
                         )
    select  dt_utc,
            dt_utc +
            extract(
                         timezone_hour
                    from
                         from_tz(cast(dt_utc as timestamp),'utc') at time zone 'Europe/Prague'
                   ) / 24 dt_prague,
            extract(
                         timezone_hour
                    from
                         from_tz(cast(dt_utc as timestamp),'utc') at time zone 'Europe/Prague'
                   ) tz_offset
      from  sample_table
    /
    
    DT_UTC              DT_PRAGUE            TZ_OFFSET
    ------------------- ------------------- ----------
    2011-10-31 13:30:00 2011-10-31 14:30:00          1
    
    SQL> 
    

    SY.

  • 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

  • Find the elapsed time between the Unix Timestamp in Actionscript 2.0

    Hello!

    I'm tryin to fiind that time passed since a Unix Timestamp.

    I have this:

         var myTime:Date = new Date(1245859691 * 1000);
         nowTime = new Date();
         oMillisElapsed = new Date(nowTime - myTime);
         
         day = numToStr(oMillisElapsed.getDate());
         min = numToStr(oMillisElapsed.getMinutes());
         sec = numToStr(oMillisElapsed.getSeconds());
         hour = numToStr(oMillisElapsed.getHours());
    

    But oMillisElapsed returns: Wed Dec 31 23:20:43 GMT - 0800 1969

    So he keeps time from 01/01/1970... Any way to make it back to something like this:

    Mon Jan 02 01 1:2:35 GMT - 0800 0000

    or something like that so I can get the days, hours, minutes and seconds.

    I use actionscript 2.0.

    Thank you!!!

    ~ Sea4Me

    You assign a new Date value, so when you try to use the Date function to get its data, you get that produce these functions, which isn't what I want.  I believe you want to get the amount of time (days, hours, minutes, etc.) between yesterday and today.  Have you tried to do what I suggested?  What you will eventually do takes the miiliseconds resulting from that and do the conversion in days, hours, seconds, etc...

  • UNIX timestamp in cfgrid controls

    Some time ago I realized a php and SQL construction. Users to apply for jobs, and the date they charge is converted into a unix timestamp and inserted in the SQL code as an integer.

    I use coldfusion more now and I'm wanting to display the results above using a cfgrid.

    I found similar posts in this forum, but I have still two EXTERNAL queries:

    (1) how do I get the date for each line before the controls cfgrid poster

    (2) how to convert unix timestamp using coldfusion

    chilliroom wrote:
    > However, the column is reading entirely the same value, I
    > calculated as the date of the last record.

    because you're not advancing through your query. I guess that the stripped News
    on the hooks for applicants.posted [i]. lets see if the cf tags get
    Thru:






  • UNIX timestamp

    I am looking for a way to convert a time value UNIX (1201900638) so that it generates a ColdFusion page in the format mm/dd/yyyy. Anyone would be able to help with that? Thank you...

    According to the time Unix the number of seconds elapsed since midnight time coordinated universal (UTC) of January 1, 1970, not counting the seconds dividers... The number of time Unix sucks at the time Unix and increases by exactly 86 400 per day since the time

    As a result, January 1, 1970 + (1201900638 / 86400) = February 1, 2008

    What is the date that is the number of "UNIX time" you have posted?

    According to the unix timestamp and epoch conversion tool, 1201900638 is equivalent to the following:

    GMT: Friday, February 1, 2008 21:17:18 UTC
    Your timezone (PDT): Friday, February 1, 2008 13:17:18

    Try this:

    #DateConvert ("utc2Local", DateAdd ("s", 1201900638, CreateDate("1970","01","01"))) #.

    Where CreateDate() converted to a date/time on January 1, 1970, Functionadds with a parameter of "s" Add 1201900638 seconds to l 'era' start date, and with "utc2Local" DateConvert() converts the time UTC to your local time.

    You can then use the DateFormat() attribute to display in any format you want.
    Phil

  • with problems of casting timestamp to date

    Hello

    So here's what I have... I have a timestamp in my database and I need to return it as a date (because what used to work in WL8.1 now gives me a java.lang.IllegalArgumentException: could not convert this to java.sql.Date in WL10). If I change my query as follows:

    I'm not running my old query to get a sample:
    Select col_key, col_time, col_other
    FROM table1 where col_key = "a".

    ... and I get to col_time * January 11, 2013 1:18:04.354261 PM'*... well.

    So, I take this value and I proceed as follows to test my format:

    Select CAST (to_timestamp (January 11, 2013 1:18:04.354261 PM', ' DD/MM/YYYY HH:MI:SS.ff PM') AS DATE) double;
    works perfectly, returns the date: 11/01/2013 13:18:04


    In view of the foregoing I apply to my old query:
    Select col_key, CAST (to_timestamp (col_time, ' MM/DD/YYYY hh:mi:ss.ff PM' ") AS DATE), col_other
    FROM table1 where col_key = "a".

    and I get a "ORA-01858: a non-digit character was found here where was waiting for a digital".

    ... where am I wrong?

    Thank you

    Martel wrote:
    Yes, it's a timestamp column...

    So okay, this is how I read online that I could convert a timestamp into date of...

    Well, what you are trying to convert a string to a timestamp and then convert the timestamp to date. That works, if you pass a string.

    If this is not the case... then how to return a timestamp as a date column?

    I already showed you in my sample code!

    I tried to_date but there is no formatting for milliseconds so why everyone suggests to_timestamp... and if this does not work then what can I do? WL10 convert timestamps java.sql.Date, so I need the request to give him a Date instead of a timestamp.

  • Convert the MySQL timestamp into a Unix timestamp field

    I have a process where I want to compare the current date with an expiration date is so many months after the date of registration. The registration date is stored as a MySQL timestamp. I want to convert this to a timestame Unix I can do the comparison with the Time() function. I tried the MySQL UNIX_TIMESTAMP both getTimestamp() PHP functions and can not get to work. I tried UNIX_TIMESTAMP in both the original SELECT statement and a stand one. I also have an error of division by zero with date_default_timezone_set function. I am attaching the screenshots of the code and the result of the echo inside. Thank you!

    Expire Test.jpg

    RegDate error.jpg

    You are far too complicated.

    SELECT TO_DAYS (reg_date) - AS TO_DAYS (CURDATE ()) daysleft

    OF ssregis

    WHERE...

    This will give you the number of days remaining before the expiry of the registration. If it is less than 0, redirect to the renewal page.

    Moreover, you yourself laying wide open to attack by SQL injection by failing to escape at the entrance of the query string. At the very least, you should do this:

    $entered_ss_id = mysql_real_escape_string($_GET['record_id']);

    $entered_email = mysql_real_escape_string($_GET['email_address']);

    However, since it seems that you are hand-coding the script, you must use MySQL improved rather than discouraged PHP MySQL functions. See http://docs.php.net/manual/en/mysqlinfo.api.choosing.php.

  • Conversion of TIMESTAMP to Date?

    Hi all

    I have this little materialized view where I use a session variable to fill.

    Say that I've seen like this.

    Select date, account, product, sum (balance) in the glbalance if date = "VALUEOF (NQ_SESSION.user_entered_date)" Grouper group by date, account, product


    Ideally, the SQL should look like: select date, account, product, sum (balance) in the glbalance if date = ' 28 / 02/2013 ' group by date, account, product



    I have a command prompt in the dashboard that fills the variable user_entered_date of query. but I defualted to a SystemDate in the repository.


    I have a report and this leads to a page of a dashboard. Whenever I open the page, it gives me an error. But when I select a date in the command prompt and run the report, and it works well.
    Its only when I open the page or the dashboard at the start, it is in error as syntax incorecct. I give the example below...


    The statement that is issued for the view in the present case is

    SET the VARIABLE user_entered_date =' TIMESTAMP "2013-02-28 00:00:00"'

    If date = "TIMESTAMP" 2013-02-28 00:00:00 "
    I'm not able to remove this word TIMESTAMP that is causing the error. How to do this?
    I have all the date columns in all the tables as DATETIME format only.


    When to start to choose the date at the COMMAND prompt, then SQL is published as: If date = ' 2013-02-28 00:00:00 ' is correct and properly executed.



    How remove the TIMESTAMP Word when I opened at the start of the dashboard... Any help?

    Current_date as good as sysdate as in Oracle.

    Use this
    SELECT dates.master_date 'DOMAIN' where dates.master_date = current_date

    For error; Difficulty is

    SELECT dates.master_date 'DOMAIN' where dates.master_date = cast (' 28 / 02/2013 ' as date)

    Check if help

    Published by: Srini VIEREN on February 28, 2013 10:49

  • How can I validate attribute (type timestamp) enter date day is not Sunday.

    Hi all

    problem is I want to validate the attribute of type timestamp. When the user select a date if the current date is Sunday as the error message

    show to the user.

    I can do this with the expression of the Groove.

    You can add a validation script to the EO attribute and use groovy as expression

    def d = newValue;
    println d.day;
    return d.day != 0;
          
    

    I have only tested with a date, but it should work with a timestamp too...

    Timo

  • Adding timestamp to date?

    How can I add a timestamp to a column in my query?

    date column is formatted as June 22, 10 '


    Select event_date_time, entity_name, EVent_log event_description

    Returns
    04-FEB-10     PROJECT     EDIT SECTION STATUS OF A PROJECT
    04-FEB-10     PROJECT     EDIT SECTION STATUS OF A PROJECT
    04-FEB-10     PROJECT     EDIT SECTION STATUS OF A PROJECT
    04-FEB-10     PROJECT     EDIT SECTION STATUS OF A PROJECT
    Published by: francislazaro on June 24, 2010 11:33

    Select to_char (sysdate, ' ' MON-DD-YYYY HH24:MI:SS) twice;
    Either ware that timestamp is the different type of data to date that can store milliseconds as well.

  • Timestamp for date columns data type are not imported in discoverer admin

    Hi all
    Someone you will suggest why timestamp data type columns are not imported into admin. discoverer other types of data import you correctly, but the timestamp data type columns are missed.

    Please let me know to change the type of data is not possible at this time.
    Thank you

    Hello
    You will be disappointed because the timestamp columns are not one of the recognized data types supported by the discoverer. He acknowledges only dates, strings and (integer and decimal) numbers.

    Maybe you could put up a view that matches the table you use, convert the timestamp in a rather ordinary date?

    Then, inside your end-user license, all you would have to do is redirect the folder to view.

    Best wishes
    Michael

  • Remove Timestamp to Date

    Hi guys,.

    I have a date with the following format:

    20:15:45.790 2008-08-11

    I need to remove the timestamp and show only:

    2008-08-11

    How can I do?

    Thank you
    Saurabh

    Hi Slim,

    Anyway you will use this column to report...

    Another Alternative:

    In the physical layer, check the data type of this column DATE...

    We have options like DATE, DATETIME, TIMESTAMP... Try to set it to this DAY...

    Hope this will help you...

    -Robin

  • How to get the timestamp of data DAQmx Read

    Hello

    I have to read 4 analog channels using DAQmx AI read in LabVIEW 2012. I am using screws DAQmx.

    Acquisition rate is 4000 samples per second, and the number of samples per channel is 200.

    I use only one task DAQmx to read the data. I get 4 data tables for 4 channels each table length is 200, every time, DAQmx Read happens.

    But I want to get the seal of these 200 samples per channel. How to get the seal of these samples, made me know.

    Thank you

    You have not indicated your code. If you choose to read the waveform data, the cluster includes t0 and dt. That's all the information you need.

  • timestamp, without date picker

    Hello

    I change format.
    TO_CHAR (SYSDATE, 'DD-MON-YYYY HH24')

    I have hard time when I tried to hide the date picker.
    One did before him?

    Thanks in advance,

    Sam

    Sorry change - to a + in the interval of calculation

    See you soon

    Ben

Maybe you are looking for

  • Why are there now TWO Adobe Flash Player required to view all of the Web sites: v11.9.900 and v12.0.0.43?

    I had Adobe Flash Player v.11.9.900.170 and upgraded to v.12.0.0.43. When I checked the Add-ons Manager, both versions of Flash were listed and active. I disabled the earlier version, and now indicate a few sites I don't have Flash. When I re-activat

  • automatic update

    How can I get my updated 8-level victory to Win 10?

  • replace iWeb

    What is the best free of replacement for iWeb? Need a facilitator and a manufacturer of web page printable free mac. I have 2 sites created with iWeb and since it is no longer supported, I had problems with updates. Can you help me?

  • With the help of LabVIEW with NI VeriStand

    Hello I try to use Labview with NI Veristand, when I followed the white paper here: http://www.NI.com/white-paper/11135/en I do not see the same menu detailed in step 4 (OR veristand is not listed on the menu - see attachment). I have NI Veristand in

  • Z30 blackBerry phone password question

    I tried 8 times to access my camera using my password, I don't know if I've forgotten my password, but one I use does not work, I tried also to enter the word blackberry followed sumbit and still nothing. I don't want my data to be deleted from my ph