Timestamp conversion

Hi,
by definition timestmaps provide date/time in UTC. With knowledge of the timezone it should be possible to calculate the local date and time explicitly. But there is no such function available in HANA. I have a timestamp field on the DB (data type DEC15 or DEC21) and want to provide an additional calculated field, showing local date, or local date/time. There is function UTCTOLOCAL, but this requires wrong importing data formats:
utctolocal(datearg,timezonearg) since it requires a datearg instead of a DEC field. It is obvious, that a correct conversion is not possible without specifying the time additionally.
How am I able to convert a timestamp into DATE and TIME fields?
Thanks and regards,
Ulf

Hi Ulf
Yep, could be that this is not doable in a calculated attribute in an analytic view...
It perfectly works in SQL, so maybe you need to change your tool here.
create column table weired_timestamp (w_ts decimal (15,0))
insert into weired_timestamp values (20140305225959)
select w_ts, to_date(w_ts), to_time(w_ts), to_timestamp (w_ts) from weired_timestamp
W_TS         
TO_DATE(W_TS)
TO_TIME(W_TS)
TO_TIMESTAMP(W_TS)  
20140305225959
2014-03-05 
22:59:59   
2014-03-05 22:59:59.0
With that you can move on with the timezone conversion.
If wonder, why
1)    the documentation provides a hard coded example only that is not really helpful :
"SELECT  UTCTOLOCAL (TO_TIMESTAMP('2012-01-01 01:00:00', 'YYYY-MM-DD HH24:MI:SS'), 'EST') "utctolocal" FROM DUMMY;
instead of a real scenario.
Well, obviously the person who wrote this hadn't had your scenario in mind.
As you're SAP internal, why don't you just provide feedback on that to the documentation team, maybe even providing an improved real-life example?
2)    the documentation doesn't refer to both scenarios, SELECTS and calculated fields in views
Likely because it's the SQL reference we are talking about here. But again, that can be a valid point for improvement - mention it to the documentation development team.
3)    the HANA documentation is wrong since utctolocal(datearg,timezonearg) should be
utctolocal(timestamparg,timezonearg) including the missing information how to convert ABAP timestamps (DEC)  into HANA timestamps (whatever it is?).
Sorry, I don't get this.
HANA provides a specific SQL compliant data type called "timestamp". This is what the functions work upon and that is what the documentation is about.
HANA is a general DBMS platform that is not just there to support the odd ends of ABAP data modelling and encoding.
I agree that there should be documentation on how to deal with ABAP data types when working without an application server. However, this shouldn't be part of the general DB documentation.
Not sure if these things are already part of any ABAP on HANA education material, but the SoH content development teams surely have come across these things and very likely documented them.
As SAP employee you got access to that, so maybe this would be a good place to look for this kind of information for you.
If you still feel this is a bug, fell free and open a internal message on that.
- Lars

Similar Messages

  • Timestamp conversion problem.

    I work in the development of a LabVIEW program that communicates with a
    server (written in Java). All acquired data is sent via TCP and the
    server can read everything (waveforms and other information). However,
    there is a problem in timestamp conversion. We don't know how to
    convert the milliseconds correctly. The timestamp is inside a waveform,
    so we cannot convert it to formatted string.
    Example:
    Original timestamp:
    13:37:19,639
    11/10/2005
    String generated with "Flatten to String":
    0000 0000 BF71 9ABF A3D7 0800 0000 0000
    Converted value (Java server):
    13:37:19,000
    11/10/2005
    Does anyone know the algorithm to obtain the milliseconds from this value: "A3D7 0800"?
    Thanks for attention.
    My regards,
    Vinicius Falseth
    Solved!
    Go to Solution.

    There is a faster way.  You can extract the timestamp from the waveform using Get Waveform Components. 
    At that point, you can convert it to whatever you want.  Attached
    is a VI which shows a simple conversion to milliseconds, losing a lot
    of resolution (128 bit timestamp goes to 52 bit double) and a more
    complex conversion showing the internal structure of the timestamp (it
    is a 128 bit fixed point number with the decimal in the middle). 
    You can modify the second conversion to do such things as throw away
    the integer portion to get higher resolution on the fraction.  Or
    you could just save to Java using a four-integer structure.
    This account is no longer active. Contact ShadesOfGray for current posts and information.
    Attachments:
    timestamp.llb ‏48 KB

  • Help to create Materialized View that has timestamp conversion

    I need help creating materialized view with timestamp conversion between GMT to LocalTime.
    Feel free to make any comments.
    Thanks in advance.
    jon joaquino;)

    Here is one way.
    1. Alter the table hist_table and add a new column pdt_timestamp.
    2. Update the new column using the function 'new_time'
    For example,
    Update hist_table
    set pdt_timestamp = new_time(gmt_timestamp,'GMT','PDT');
    3. create a materialized view log on the table 'hist_table' using the syntax
    create materialized view log on hist_table
    with primary key, rowid, sequence;
    4. create a materialized view now using the syntax:
    (You have to specify your own storage numbers and tablespace name)
    create materialized view mview_hist_table
    pctfree 0 tablespace mymview
    storage (initial 16k next 16k pctincrease 0)
    build immediate
    refresh fast on commit
    as select uid,gmt_timestamp,pdt_timestamp
    from hist_table;
    Please test on your test instance before doing it on production. I have tested this on Oracle 10g for Windows 2000. I assumed that column 'uid' is the primary key on the table. I hope this helps.
    **********************************************************

  • Help... Timestamp Conversion

    Hi All,
    I need to compare LONG datatype with TIMESTAMP,how can i include it in the WHERE clause?
    E.g; i need to find last 3 days data.
    EMP Table
    EmpNo - NUMBER
    Ename - VARCHAR2
    Entry_Point - LONG datatype
    SELECT *
    FROM emp
    WHERE TRUNC(entry_point) <= TRUNC(SYSTIMESTAMP) - 3;
    Above query is showing conversion error.
    Please help!

    Hello Saubhik,
    Sorry for the late reply.
    I saw your code with respect to DBMS_LOB.SUBSTR; but there are some error encountered.
    Plz find code below.
    DECLARE
         CURSOR cur IS
            SELECT partition_name,table_name, high_value FROM dba_tab_partitions
            where table_owner='MIT'
            and table_name='ORDER_HDR' ;
          vpart dba_tab_partitions.partition_name%type;
          vtab  dba_tab_partitions.table_name%type;
          v_high LONG;
        BEGIN
          OPEN cur;
          LOOP
            FETCH cur INTO vpart,vtab,v_high;
           EXIT WHEN cur%NOTFOUND;
           IF DBMS_LOB.substr(v_high,11,1)<= TRUNC(SYSTIMESTAMP) - 3 THEN
            dbms_output.put_line(v_high||' Matched');
           END IF;
         END LOOP;
         CLOSE cur;
       END;Error
    An error was encountered performing the requested operation:
    ORA:01858: a non-numeric character was found where a numeric was expected
    ORA:06512: at line 16
    018518.00000 - "a non-numeric character was found where a numeric was expected"
    *cause: The input data to be converted using a data format model was incorrect.
         The input data did not contain a number where a number was required by the format model
    *action: Fix the input data or the format model to make sure the elements match in number and type. Then re-try the operation.
    Error at line:2
    Entry in the table - DBA_TAB_PARTITIONS
    partition_name table_name high_value
    ===========================
    SYS_P234645 ORDER_HDR TO_DATE(' 2010-06-09 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')
    SYS_P235118 ORDER_HDR TO_DATE(' 2010-07-21 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')
    Edited by: Sunil G on Sep 28, 2010 5:39 AM
    Edited by: Sunil G on Sep 28, 2010 5:40 AM

  • DB2 timestamp to oracle timestamp conversion

    Does any one know how to convert Db2 timestamp into oracle timestamp.
    From DB2 we are getting timestamp in this format (2000-03-06-16.02.19.074474) (26 bytes).
    I want to insert this into oracle thru owb into oracle table with column type timestamp.
    Does anyone know the procedure for this type of conversion
    Thanks in advance..

    Hi,
    Try a migration tool at www.ispirer.com/chyfo.html
    It provides you the fastest, the easiest and the most powerful way to migrate
    DB2 database into Oracle.
    It works in conjunction with Oracle SQL Loader. The tool creates text files (moving of LOBs are fully supported), generates
    CREATE TABLE scripts for Oracle and control files for SQL Loader.
    The tool has a lot of other features.
    Best regards, Dmitry.
    null

  • Urgent Help - Timestamp conversion in ORACLE 9i

    Hi Friends
    I need a help .We are using DB servers at different GEOgraphical locations. The timestamp is stored as GMT/UTC using the conversion function SYS_EXTRACT_UTC . But when retrieving from DB again I need to convert to the equivalent local time of DB Server . Is there is any way to do this?
    Thanks in advance
    gopal

    Mr Gopal
    I am also having the same problem .
    If you find the answer pl mail to me
    thanks in advance.
    Suresh

  • Timestamp conversion error in BPEL

    My BPEL process queries a date Column using sql query and inserts the data into the timestamp column of a table.
    I am getting following error in the BPEL process.
    insert failed. Descriptor name: InsertEdrmsRetentionUpdates.EdrmsRetentionupdates. Caused by: Unparseable date: "2009-10-20 10:13:25.000"
    Caused by Exception TOPLINK-3001 (Oracle TopLink - 10g Release 3 (10.1.3.4.0) (Build 080602)): oracle.toplink.exceptions.ConversionException
    Exception Description: The object xs:datetime 2009-10-20 10:13:25.0, of class class java.lang.String, could not be converted to class java.sql.Timestamp.
    Internal Exception: java.text.ParseException: Unparseable date: "2009-10-20 10:13:25.000".
    What is going wrong?
    Please help its very urgent..
    Thanks,
    Prasanna

    Fixed..
    Datatype of the Date Column in the DBAdapter for sql query was String.
    I changed it to xs:dateTime manually and it worked.
    --Prasanna                                                                                                                                                                                                                                                                                                       

  • String to timestamp conversion

    I have a string of the format yyyyMMdd:hh:mm:ss.SSSSS.
    I need to convert it to a timestamp value of
    the format dd-MMM-yy hh.mm.ss.SSSSS.
    I tried the following
    SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd:hh:mm:ss.SSSSS");
    java.util.Date date = sdf.parse(stdate);
    java.sql.Timestamp t = new java.sql.Timestamp(date.getTime());
    but it didnt work.
    Any help will be greatly appreciated.

    I have a string of the format
    yyyyMMdd:hh:mm:ss.SSSSS.
    need to convert it to a timestamp value of
    he format dd-MMM-yy hh.mm.ss.SSSSS.
    I tried the following
    SimpleDateFormat sdf = new
    SimpleDateFormat("yyyyMMdd:hh:mm:ss.SSSSS");
    java.util.Date date = sdf.parse(stdate);
    java.sql.Timestamp t = new
    java.sql.Timestamp(date.getTime());
    but it didnt work.
    Any help will be greatly appreciated.
    I have a string of the format
    yyyyMMdd:hh:mm:ss.SSSSS.
    need to convert it to a timestamp value of
    he format dd-MMM-yy hh.mm.ss.SSSSS.Timestamps do not have a format - they are just a point in time. The toString() method will return a String representing the Timestamp in some format but this is not the same as having a format.
    I tried the following
    SimpleDateFormat sdf = new
    SimpleDateFormat("yyyyMMdd:hh:mm:ss.SSSSS");
    java.util.Date date = sdf.parse(stdate);
    java.sql.Timestamp t = new
    java.sql.Timestamp(date.getTime());
    but it didnt work.What do you mean by "didn't work"?

  • Unix timestamp conversion to human readable representation ...

    Hi,
    I map unix timestamps from MaxDB to the controller context of Web Dynpro and display the results in a table. Is there a smart way to convert the timestamps to human readable date and time? Maybe some way to manipulate the table values with a function before they are written ..?
    For now, I create a new node in the context and manually set each value with the according date/time representation ... but thats pretty cumbersome.
    Thank you very much for your help!
    Cheers,
    boris

    Hi Boris,
    Check http://java.sun.com/j2se/1.3/docs/api/java/text/SimpleDateFormat.html
    Date currentTime_1 = new Date(longUnixTimestamp);
    String dateString = formatter.format(currentTime_1);
    I would suggest you to create a calculated attribute under the same node as initial timestamp value and return a result of SimpleDateFormat.format().
    Best regards, Maksim Rashchynski.

  • Unix timestamp to Oracle timestamp conversion

    Hi all,
    I am trying to convert the UNIX timestamp to ORACLE timestamp .
    I have done like this upto now.
    CREATE OR REPLCACE FUNCTION unixts_to_oraclets(unixtimestamp IN INTEGER)
    RETURN DATE IS
    result DATE;
    BEGIN
    result := TO_DATE('1970-01-01', 'YYYY-MM-DD') + numtodsinterval(unixtimestamp, 'SECOND');
    return(result);
    end unixts_to_oraclets;
    now i have run this query
    SQL> select unixts_to_oraclets(1139291114) as TS from dual;
    TS
    07-FEB-06
    now i need the ouput to like this 07-FEB-06 01:10:12
    for that i have done like this:
    DECLARE
    v_date DATE;
    res_date DATE;
    BEGIN
    SELECT from_uts(1139291114)INTO v_date FROM dual;
    SELECT TO_TIMESTAMP(v_date,'DD-MON-RRHH24.MI.SS.FF') INTO res_date FROM dual;
    DBMS_OUTPUT.PUT_LINE(res_date);
    END;
    but the output is :
    SQL> /
    07-FEB-06
    PL/SQL procedure successfully completed.
    why is that it is not printing 07-FEB-06 01:10:12 ?
    how should i moodify the code to get the desired output.
    please help me i this regard
    Trinath Somanchi,
    Hyderabad.

    SQL> exec dbms_output.put_line(sysdate);
    07-FEB-06
    PL/SQL procedure successfully completed.
    SQL> exec dbms_output.put_line(to_char(sysdate, 'DD-MM-YYYY HH24:MI:SS'));
    07-02-2006 02:48:35
    PL/SQL procedure successfully completed.
    SQL> alter session set nls_date_format='DD-MM-YYYY HH24:MI:SS';
    Session altered.
    SQL> exec dbms_output.put_line(sysdate);
    07-02-2006 02:49:03
    PL/SQL procedure successfully completed.

  • Time String to Timestamp Conversion Problem

    Hi,
    I attempted to convert time string to timestamp but I failed. What is the wrong with it? I need a timestamp to create waveforms.
    Egemen
    Solved!
    Go to Solution.
    Attachments:
    Time String to Timestamp.png ‏18 KB

    You are right Gogineni, when I got the error, I was using %S in the format string for Format Date/Time String function and %3u in the format string for Scan From String.
    I found the solution in this thread - use %S%3u in both places.
    Help the forum when you get help. Click the "Solution?" icon on the reply that answers your
    question. Give "Kudos" to replies that help.

  • Error in timestamp conversion

    I use an attribute definede oracle.jbo.domain.Timestamp but when I use the getTime() method I get an incorrect result (meaningless, sometime it reverse the natural time direction).
    How can I solve that issue ?
    TIA
    Tullio

    Did you create a TimeStamp attribute in the Entity Object?
    This would be requried for sql type DATE attributes.
    Using JDev 9i
    You can create a date and time format (display both) to display an attribute value that is SQLType DATE, but you must first change the attribute type definition on the attribute's entity object to Timestamp. To change the attribute's type: Expand the Business Components project in the Navigator and locate the entity object that defines the attribute for which you want to create the format. Right-click the entity object in the Navigator and choose Edit EOName. In the Entity Object Wizard, select Attribute Settings and choose the desired attribute from the Select Attribute dropdown list. Note: By default the attribute should show a type of Date to match its database column type. Choose Timestamp from Type on the attribute settings page. Click OK to save the attribute with the new type.

  • Java time to DB2 timestamp conversion

    I want to convert current time to following format "2008-01-12 11:46:55.945000". I tried but I an not able to do. Could you pelase hlep me out or is there any easy way to do
              Calendar calendar = Calendar.getInstance();
              //2008-01-12 11:46:55.945000
              int year = calendar.get(Calendar.YEAR);
              int date = calendar.get(Calendar.DATE);
              int month = calendar.get(Calendar.MONTH);
              int hour = calendar.get(Calendar.HOUR);
              int minite = calendar.get(Calendar.MINUTE);
              int second = calendar.get(Calendar.SECOND);
              int millisecond = calendar.get(Calendar.MILLISECOND);
              String timestamp = year+"-"+date+"-"+month+" "+hour+":"+minite+":"+second+"."+millisecond;

    have you try like:
    java.sql.Timestamp creationdate = new java.sql.Timestamp(new Date().getTime());
    prepStmt.setTimestamp(1, creationdate);or format the date as "yyyy-MM-dd HH:mm:ss" like string by using SimpleDateFormat
    and use
    java.sql.Timestamp creationdate =
                   java.sql.Timestamp.valueOf(creationDate);

  • 10g Oracle Timestamp conversion to milliseconds

    Hello!
    I'm sure this is possible and I have found a couple of references but none that work.
    How can I take an Oracle Timestamp and convert it using a SELECT statement into milliseconds?
    Thanks in advance

    It looked interesting but I don't think it is the answer.
    Isn't the Oracle timestamp based on the elapsed seconds since some date in 1970 or something? It seems there should be an algorithm to convert but I just haven't found it.

  • Timestamp Conversion Function Module

    Hi all,
    >>We are bringing time stamp value (like 20072404161312) from CRM ,we need to convert into date & time. I need function module which one does this...
    >>We are are storing the time duration in min format (its key figure). I need to populate in reports as HR:MN:SS , How we can do this? Is there any function module is available for this?
    Thanks in Advance

    Hello Arun,
    The timestamp is in the format <date><time>. In your example (20072404161312), the date is 20072404 and time is 161312. You can transfer the timestamp into a string and then split the data. You can use the following ABAP code to separate the date from the time:
    * w_ts is your timestamp, w_s is the temporary string
    *w_date and w_time will be your final date and time.
    data: w_ts type timestamp.
    data: w_s type string.
    data: w_date type sy-datum,
          w_time type sy-uzeit.
    w_ts = '20072404161312'.
    * Here is the code you need:
    w_s = w_ts.
    w_date = w_s(8).
    w_time = w_s+8(6).
    Hope this helps.
    Hope this helps.

Maybe you are looking for

  • Not getting data in OBIEE report while pulling columns from different DB

    Hi All, I am creating a report in OBIEE 11g which uses Table A and table B which are joined in both physical layer and BMM layer. But somehow I am not getting any data in the report where as data is actually present for the matching joining columns.

  • Got an error while import script run in command prompt in R12

    hi ' i am running the below script in command prompt in R12, but it will give an error that error name: 'import' is not recognized as internal or external command, operable program or batch file. import C:\JDeveloper10g\jdevhome\jdev\myprojects\flsm\

  • Slow exporting slide show as video.  4 days less than 10%

    I am exporting a timelapse of 1900 Small Raw slide show images as video.  It can run for 4 days and not much seems to happen. I had done 1500 images in less than an hour before and they were larger files.  What can I do?

  • Problem: check random array with a static value

    My goal is to use the random number generator to put numbers into randomArray, then do a linear search to try to find if the number 5 has been generatated. Next print out where in the array the value can be found. I have no compile errors but I have

  • 8800GT palette problems?

    I just received my 8800GT upgrade for my "original" Mac Pro. I had seen a couple of instances of the palette getting "screwed up" after a long period of time, which I thought might be a problem with heating (my 1900XT had all sorts of problems). Look