Strange Timestamp value problem

Hi gurus,
Please help me. And thanks in advance!
I have a stored procedure that creates an xml document, which includes a timestamp value converted from a date type column. When this procedure is run through a job, the converted timestamp value is considered invalid by our partner in that it has a plus (+) sign and some 0's at the end. But when I run the procedure manually from SQL*Plus, the timestamp value comes out valid. Here is what I have for the results.
Result when run from within the server through a job:
<ScheduleFor>
<ScheduledDateTime>2007-10-23T10:15:43+00:00</ScheduledDateTime>
</ScheduleFor>
Result when manually run from SQL*Plus:
<ScheduleFor>
<ScheduledDateTime>2007-10-23T10:16:36-05:00</ScheduledDateTime>
</ScheduleFor>
And here is the SQL for the above:
select xmlelement("ScheduleFor",
     xmlelement("ScheduledDateTime", to_char(to_timestamp_tz(to_char(sysdate,
     'YYYY-MM-DD HH24:MI:SS'), 'YYYY-MM-DD HH24:MI:SS.FF'),'YYYY-MM-DD"T"HH24:MI:SSTZH:TZM'))
     ) into v_xml
     from dual;
Does anyone have an idea why I get this? We are on Oracle 10g Enterprise Edition Release 10.2.0.3.0.
Thanks a lot.
Ben

Thanks again! You are right. This does change the time zone to 8:0:
ALTER SESSION SET TIME_ZONE = '-8:0';
select xmlelement("ScheduleFor",
xmlelement("ScheduledDateTime", to_char(to_timestamp_tz(to_char(sysdate,
'YYYY-MM-DD HH24:MI:SS'), 'YYYY-MM-DD HH24:MI:SS.FF'),'YYYY-MM-DD"T"HH24:MI:SSTZH:TZM'))
from dual;
<ScheduleFor><ScheduledDateTime>2007-10-24T08:37:05-08:00</ScheduledDateTime></ScheduleFor>
I will tell the DBA to fix it.
Thanks again!
Ben

Similar Messages

  • Reading Timestamp value into an SSIS variable

    I need to read the last timestamp value (MAX(TimeStampValue)) from a table, store it in a variable in SSIS and using the variable, perform a comparison against another table and load delta records. 
    The string data type is not playing well with the timestamp data type and things get even more complicated if I try to store the timestamp value as a varchar in a table.
    Is there any variable data types in SSIS that will store the timestamp value easier than a string?

    It could be due to the time stamp value being incompatible with the date time functions which you need to fix.
    So to make it conform manipulate on its value to get the proper format.
    PS: Varchar WILL swallow any text, please be more specific, think how others would be reproducing YOUR issue.
    Arthur My Blog

  • Rounding off value problem in sales order

    Hi All,
    This is related to a rounding off value problem in sales order.
    The problem is described by an example which is as follows -
    Selling Price of Material A = Rs. 176.76
    Excise charged = Rs. 21.80
    Total Price = Rs.176.76 + Rs.21.80 = Rs. 198.56
    On this total Trade Discount (ZDTD) having access sequence,is calculated  at the rate of 4% = Rs. 7.94
    But the condition base value after the discount is showing Rs.198.60 instead of Rs.198.56
    I want the system to reflect the value as Rs.198.56 intact and it should not round up to the nearest value i.e. Rs. 198.60
    Why is this happening? Is it possible to reflect the exact value? If yes what is needed to be done?
    The commercial round off is activated for the DIFF Condition Type.
    Looking forward to some valuable suggestions.
    Thanks & Regards
    Priyanka Mitra

    Hi Ramesh,
    Thanks for your suggestion but the problem has been solved by me.
    Regards
    Priyanka Mitra

  • SQL*Loader and timestamp values

    I'm loading timestamp values (among other data) from a text file into Oracle using SQL*Loader.
    The data I load is formatted like the following:
    2008/11/13 23:55:21.366
    2008/11/13 23:55:22.782
    2008/11/13 23:55:25.879
    Hence my control file look like this:
    TSTAMP TIMESTAMP "YYYY/MM/DD HH24:MI:SS.FF",
    The timestamp data in the input file are in UTC, however I load into a column that is of type "TIMESTAMP(3)", i.e. in server time. This is on purpose. I do not want the data to be in UTC when I look at them.
    Therefore after the load I have to manually do
    UPDATE mytable
    SET tstamp = tstamp + (tstamp - sys_extract_utc(tstamp));
    This update-after-loading actually takes quite some time due to the amount of records. I would like to avoid it and instead do it as part of the load. Is this possible somehow?
    I'm on Oracle 10.2.
    Thanks.

    Hi
    What about setting a special Time Zone in your database?
    You have two options when setting which time zone the database belongs to. You can either qualify it as a displacement from GMT/UTC in the format of 'hh:mm' or you can specify it as a name that has an entry in the V$TIMEZONE table.
    select tzname,tzabbrev from V$TIMEZONE_NAMES;
    select DBTIMEZONE from dual;
    ALTER database SET TIME_ZONE = 'Denmark/Copenhagen';
    select SESSIONTIMEZONE from dual;
    select CURRENT_TIMESTAMP from dual;
    See that link
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14231/create.htm#sthref319
    Edited by: Hub on Dec 7, 2008 3:58 PM

  • How to compare 2 timestamp value (in terms of minutes)

    Hi all.
    I've got 2 timestamp value a,b. I would like to count the different (in terms of minutes).
    I tried a.compareTo(b), but it's not work.
    pls help.
    Thanks
    Regards,
    Kin

    I assume by "timestamp value" you mean Dates or longs.
    Ever thought of basic maths?
    date a - date b? Dates can be expressed in longs, as you might know.
    For more info read the API.

  • Difference in timestamp values

    Hi,
    We have a project for like to like migration for R12 to R16, but ther are differences in the timestamp values calulated between the two enviornments
    The R12 Production server is 5 hrs head of R16 production server.
    i have applied the following formula to both the production report:
    Timestampdiff(SQL_TSI_MINUTE,TIMESTAMP '2009-07-06 12:12:12',TIMESTAMP '2009-08-07 11:11:11')
    the results are in Minutes:
    R12:44578
    R16:46019
    Is this because of the difference in server timing? or R16 has a feature to calulate the difference without considering the timezones, daylight saving etc which the R12 lacks, because when i checked which of the 2 difference is correct, the R16 differnce seems to be correct.
    Please share your thoughts on this as it is affecting large no .of reports.
    Many Thanks

    /* Formatted on 2012/04/12 15:56 (Formatter Plus v4.8.8) */
    DECLARE
       v_time1       date;
       v_time2       date;
       v_time_diff   number;
    BEGIN
       SELECT To_Date(TO_CHAR (wss_gdp_time, 'DD-MON-YYYY HH12:MI:SS'),'DD-MON-YYYY HH12:MI:SS')
         INTO v_time1
         FROM tab1
        WHERE wss_gdp_time = (SELECT MAX (wss_gdp_time)
                                FROM tab1) AND ROWNUM <= 1;
       SELECT to_Date(TO_CHAR (wss_gdp_time, 'DD-MON-YYYY HH12:MI:SS'),'DD-MON-YYYY HH12:MI:SS')
         INTO v_time2
         FROM tab1
        WHERE wss_gdp_time = (SELECT MAX (wss_gdp_time)
                                FROM tab1
                               WHERE wss_gdp_time < (SELECT MAX (wss_gdp_time)
                                                       FROM tab1))
          AND ROWNUM <= 1;
       SELECT ((v_Time1-v_time2) * 1440)
         INTO v_time_diff
         FROM DUAL;
       DBMS_OUTPUT.put_line (v_time1 || ' ' || v_time2 || ' ' || v_time_diff);
       IF v_time_diff > '10'
       THEN
          DBMS_OUTPUT.put_line ('ALERT');
       ELSE
          DBMS_OUTPUT.put_line ('No ALERT');
       END IF;
    END;
    /

  • I have a strange 3g data problem.

    I have a strange 3g data problem.  At home I have zero 3G connectivity even though all bars are showing and says "3G" and wifi is "Off" ... unless I am on the phone and then magically the 3G data connection works perfectly!!  Does anyone have any idea what is happening?  Also when I bring my phone to my dad's or my friends house the problem disappears!! Is this a hardware or a AT&T network problem? os is 4.3.3
    Also called ATT and they said there was no problem with the network and that it was a hardware issue.  Also restored the phone several times but the problem did not go away.

    OK, no trouble shooting. The first thing I'd attempt is restarting in Safe Mode. If you still don't have luck try doing both a SMC and PRAM reset, it wouldn't hurt to do the SMC reset a couple of times. If still no luck let us know.
    SMC RESET
    Shut down the computer.
    Unplug the computer's power cord and all peripherals.
    Press and hold the power button for 5 seconds.
    Release the power button.
    Attach the computers power cable.
    Press the power button to turn on the computer.
    PRAM RESET
    Shut down the computer.
    Locate the following keys on the keyboard: Command, Option, P, and R. You will need to hold these keys down simultaneously in step 4.
    Turn on the computer.
    Press and hold the Command-Option-P-R keys. You must press this key combination before the gray screen appears.
    Hold the keys down until the computer restarts and you hear the startup sound for the second time.
    Release the keys.

  • Difference in minutes for two timestamp values

    Dear All,
    I am having two timestamp values and need to calculate the total time in minutes between them and store in a variable.
    Can you please help me.
    Eg:
    T1 = 12-APR-12 06.01.56.000000 AM
    T2 = 10-APR-12 06.14.32.000000 AM
    I want to have T3 as the total time difference beteween T1 and T2 in minutes.
    Not able to convert +000000001 23:47:24.000000000 in minutes
    The above value I got was by just substracting T1 and T2
    Thanks!

    /* Formatted on 2012/04/12 15:56 (Formatter Plus v4.8.8) */
    DECLARE
       v_time1       date;
       v_time2       date;
       v_time_diff   number;
    BEGIN
       SELECT To_Date(TO_CHAR (wss_gdp_time, 'DD-MON-YYYY HH12:MI:SS'),'DD-MON-YYYY HH12:MI:SS')
         INTO v_time1
         FROM tab1
        WHERE wss_gdp_time = (SELECT MAX (wss_gdp_time)
                                FROM tab1) AND ROWNUM <= 1;
       SELECT to_Date(TO_CHAR (wss_gdp_time, 'DD-MON-YYYY HH12:MI:SS'),'DD-MON-YYYY HH12:MI:SS')
         INTO v_time2
         FROM tab1
        WHERE wss_gdp_time = (SELECT MAX (wss_gdp_time)
                                FROM tab1
                               WHERE wss_gdp_time < (SELECT MAX (wss_gdp_time)
                                                       FROM tab1))
          AND ROWNUM <= 1;
       SELECT ((v_Time1-v_time2) * 1440)
         INTO v_time_diff
         FROM DUAL;
       DBMS_OUTPUT.put_line (v_time1 || ' ' || v_time2 || ' ' || v_time_diff);
       IF v_time_diff > '10'
       THEN
          DBMS_OUTPUT.put_line ('ALERT');
       ELSE
          DBMS_OUTPUT.put_line ('No ALERT');
       END IF;
    END;
    /

  • To get previous day timestamp of a timestamp value in java

    Hi,
    I have a timestamp variable, say settledTimeStamp which is passed as a runtime argument to a query. I should also send another timestamp variable say previousTimeStamp whose value should be previous day timestamp, ie for settledTimeStamp.
    For example,
    Todays date= May 9th 2008.
    say settledTimeStamp to May 7th 2008.
    I should get the timestamp value for previous day to SettleDate i.e May 6th, 2008.
    I am showing this as an example because I tried with Calendar options too but it takes current timestamp and gives previous days timestamp which is not the same as I required. Like it returns May 8th as my previousTimeStamp if I work with Calendar options....
    Can anyone help me on this?

    An object of the Calendar class represents a specific point in time. The fields, such as DAY_OF_MONTH, allow you to access meaningful parts of that specific point in time and use them. Calendar.DAY_OF_MONTH is a field, and it doesn't represent the "current day" or any particular point in time at all. It's used to ask a particular Calendar object what its DAY_OF_MONTH is.
    import java.util.Calendar;
    public class Test {
         public static void main(String[] args) {
              Calendar cal = Calendar.getInstance();
              cal.setTimeInMillis(99999999999L);
              int year = cal.get(Calendar.YEAR); //cal, what is your YEAR?
              System.out.println(year);
              int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK); //cal, what is your DAY_OF_WEEK?
              System.out.println(dayOfWeek);
              boolean inApril = Calendar.APRIL == cal.get(Calendar.MONTH); //cal, are you in the month of APRIL?
              System.out.println(inApril );
              System.out.println(cal); //cal, tell me all about yourself
    }Really, the documentation can do a better job explaining it than I can. Read it. And there are numerous Calendar and Date tutorials all over the internet. Date processing in java is not the easiest thing, so it can take a bit of getting used to, but you will have to read the documentation and write code yourself to understand it.
    Oh, and you mark your question as answered and then dispense duke stars to posts you felt were helpful. I don't think people here really care much about them.

  • Get the timestamp value in the form of array of 8 bytes, whileretrieving da

    3) How we can get the timestamp value in the form of array of 8 bytes, while retrieving the data?
    4.) How we can pass the 8 byte array to stored procedure? What will the data type of the parameter?

    duplicate post:
    timestamp value in the form of array of 8 bytes

  • Timestamp value in the form of array of 8 bytes

    1) How we can get the timestamp value in the form of array of 8 bytes, while retrieving the data?
    2) How we can pass the 8 byte array to stored procedure? What will the data type of the parameter?

    1). using to_char
    SQL> select to_char(systimestamp, 'ddmmyyyy') from dual ;
    TO_CHAR(
    10052006
    SQL>2). as varchar2, and use to_timestamp to convert to timestamp:
    SQL> select to_timestamp('10052006', 'ddmmyyyy') from dual ;
    TO_TIMESTAMP('10052006','DDMMYYYY')
    10-MAY-06 12.00.00.000000000 AM
    SQL>

  • DB timestamp value with JVM TimeZone

    Hi all,
    If we have database timestamp "*1970-01-01T16:00:00*", no matter what Time Zone the jvm is running with, we get the java.sql.Timestamp object representing the time "1970-01-01T16:00:00" locally(Shang Hai, Las Vegas, London...). So, the UTC time will be different as well.
    I need to do some conversion work to make database timestamp "1970-01-01T16:00:00" as UTC time. Although it will be different in jvms with different time zones, they all mean the same time(UTC time, same million seconds from UTC Time 1970-01-01T00:00:00.000) and will be consistent.
    For how to do the conversion, do you have any suggestion?

    Seems like an odd request.
    1. If your database does NOT specify a timezone then the jdbc connection string would have a way to do that explicitly.
    2. If you database DOES specify a timezone then you would need to write SQL (not java) that returned a unspecified timezone value, probably a string, which you would use to create a java timestamp (for example via SimpleDateFormat).
    The above or course presumes that you understand that the jdbc has perfectly acceptable ways of getting correct timestamps from databases and that displaying a timestamp value has nothing to do with that.

  • Very strange EL evaluation problem

    Hi,
    I have a very strange problem atm.
    I'm trying the JNDI Resources example on tomcat.
    My test.jsp page looks like this:
    <%@ page contentType="text/html;charset=UTF-8" language="java" %>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>
    <html>
    <head>
    <title>DB Test</title>
    </head>
    <body>
    <h2>Results</h2>
    <c:out value="${1+2+3}"/>
    <sql:query var="rs" dataSource="jdbc/JavaTest">
    select id, foo, bar from testdata
    </sql:query>
    <c:out value="${rs.rowCount}"/>
    <c:forEach var="row" items="${rs.rows}">
    Foo ${row.foo}
    Bar ${row.bar}
    </c:forEach>
    <br>
    </body>
    </html>
    The output of this page is this:
    Results
    ${1+2+3} ${rs.rowCount} Foo ${row.foo}
    Bar ${row.bar}
    As you can see these expressions are just written out to the browser and they are not being evaluated.
    The problem is not with tomcat itself because other jsp's without database access work perfectly.
    My web.xml file looks as follows:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
    <description>MySQL Test App</description>
    <resource-ref>
    <description>blah</description>
    <res-ref-name>jdbc/JavaTest</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    </resource-ref>
    </web-app>
    my context.xml file looks as follows:
    <Context path="/DBTest" docbase="DBTest.war" debug="5" reloadable="true" crossContext="true" useNaming="true">
    <Logger className="org.apache.catalina.logger.FileLogger"
    prefix="localhost_DBTest_log." suffix=".txt" timestamp="true"/>
    <Resource name="jdbc/JavaTest"
    auth="Container"
    type="javax.sql.DataSource"/>
    <ResourceParams name="jdbc/JavaTest">
    <parameter>
    <name>factory</name>
    <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
    </parameter>
    <parameter>
    <name>maxActive</name>
    <value>100</value>
    </parameter>
    <parameter>
    <name>maxIdle</name>
    <value>30</value>
    </parameter>
    <parameter>
    <name>maxWait</name>
    <value>10000</value>
    </parameter>
    <parameter>
    <name>username</name>
    <value>THiNG</value>
    </parameter>
    <parameter>
    <name>password</name>
    <value>**********</value>
    </parameter>
    <parameter>
    <name>driverClassName</name>
    <value>com.mysql.jdbc.Driver</value>
    </parameter>
    <parameter>
    <name>url</name>
    <value>jdbc:mysql://localhost:3306/javatest?autoReconnect=true</value>
    </parameter>
    <parameter>
    <name>removeAbandoned</name>
    <value>true</value>
    </parameter>
    <parameter>
    <name>logAbandoned</name>
    <value>true</value>
    </parameter>
    <parameter>
    <name>removeAbandonedTimeout</name>
    <value>300</value>
    </parameter>
    </ResourceParams>
    </Context>
    I've included the jstl.jar and standard.jar from the jstl package in the WEB-INF/lib directory, also the mysql-connector-java.jar (JDBCDriver) is included in the web-inf/lib directory.
    Here is the logfile, which might contain the answer to my problem: (I removed the ResourceRef specification because it's exactly the same as in the context.xml file)
    2004-09-29 13:45:01 NamingContextListener[Catalina/localhost/DBTest]: Resource parameters for jdbc/JavaTest = ResourceParams[]
    2004-09-29 13:45:01 NamingContextListener[Catalina/localhost/DBTest]: Adding resource ref jdbc/JavaTest
    2004-09-29 13:45:01 NamingContextListener[Catalina/localhost/DBTest]: ResourceRef[............]
    2004-09-29 13:45:01 NamingContextListener[Catalina/localhost/DBTest]: Resource parameters for UserTransaction = null
    2004-09-29 13:45:10 NamingContextListener[Catalina/localhost/DBTest]: Resource parameters for jdbc/JavaTest = ResourceParams[......................]
    2004-09-29 13:45:10 NamingContextListener[Catalina/localhost/DBTest]: Adding resource ref jdbc/JavaTest
    2004-09-29 13:45:10 NamingContextListener[Catalina/localhost/DBTest]: ResourceRef[...........]: Resource parameters for UserTransaction = null
    Can somebody help me with this. I've been looking for a sollution for hours.
    I've been having problems setting up the jdbc-driver also, but I think this is solved now with these deployment descriptors. I don't have a single clue what is going on right now.
    ${} expression are simple NOT being evaluated.
    I don't think it's a database problem because I can see the user connections in the mysql monitor.
    Any ideas? All help is welcome and very much appreciated. :-)
    THANKS !!!
    PS: sorry for the extreme long post, I wanted to post all relevant information to track this strange behaviour down.

    Seems to be a problem with your web.xml not pointing to version 2.4.
    Just check this link too:
    http://www.mail-archive.com/[email protected]/msg07006.html
    HTH

  • 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

  • AFS Grid value problem

    Hello,
            After i create a sales order in va01, and want to change the quantity in va02 tcode. I select AFS ITEM and edit the quanity, after i save it and again enter using va02, in the grid value i.e., matrix entry all the items i entered is missing. And most of the times the quanitiy is doubling. i.e., if 500 units of shirts were entered in va01, here automatically it doubles. My client is facing this problem. Is there a SAP PATCH error??
      Thanks in Advance.

    Hello,
    What's your AFS release ?
    That's pretty strange, I know almost all AFS releases and never faced such an issue. I would recommend first to check whether a malicious user exit could be the cause of the error. If that's not the case, note that there is no available AFS features that deletes entered schedule line/grid value. Only reason for rejection can be automatically populated in sales order due to wrong grid value, ATP check...etc...
    The last option will be to raise a customer note.
    Best regards,
    Mehdi

Maybe you are looking for