Doubt using  to_timestamp

I have a table A with Timestamp data type.
DATE1 TIMESTAMP
SELECT DATE1 FROM A
02-AUG-12 01.45.02.222000000 PM
02-AUG-12 01.45.02.222000000 PM
02-AUG-12 10.45.02.222000000 AM
02-AUG-12 01.45.02.222000000 PM
I want to add 1 year to this date and on the result I want to see the fraction as well.
But when I add 365 I am loosing the time and fraction part even after converting to TO_TIMESTAMP.
SELECT DATE1, DATE1 +365, to_timestamp(DATE1 +365,'yyyy-mm-dd hh:mi:ss.ff') FROM A
02-AUG-12 01.45.02.222000000 PM     02-AUG-13     13-AUG-02 12.00.00.000000000 AM
02-AUG-12 01.45.02.222000000 PM     02-AUG-13     13-AUG-02 12.00.00.000000000 AM
02-AUG-12 10.45.02.222000000 AM     02-AUG-13     13-AUG-02 12.00.00.000000000 AM
02-AUG-12 01.45.02.222000000 PM     02-AUG-13     13-AUG-02 12.00.00.000000000 AM
Is there a way I can add 1 year to date and yet see the fraction part of the date?
Thanks

user625850 wrote:
Thanks for quick response. I am able to get the time and added an year too. NUMTOYMINTERVAL.Well, not exactly. Adding interval adds it literally. Adding interval '1' year simply bumps up year by 1. Therefore, if your date is February 29, adding interval '1' year will fail:
SQL> select to_timestamp('29-FEB-12 01.45.02.222000000 PM','dd-mon-rr hh.mi.ss.ff9 pm') + interval '1' year from dual
  2  /
select to_timestamp('29-FEB-12 01.45.02.222000000 PM','dd-mon-rr hh.mi.ss.ff9 pm') + interval '1' year from dual
ERROR at line 1:
ORA-01839: date not valid for month specified
SQL> I gave you solution to add 365 days. If you want to add 1 year:
with sample_table as (
                      select to_timestamp('02-AUG-12 01.45.02.222000000 PM','dd-mon-rr hh.mi.ss.ff9 pm') date1 from dual union all
                      select to_timestamp('02-AUG-12 01.45.02.222000000 PM','dd-mon-rr hh.mi.ss.ff9 pm') from dual union all
                      select to_timestamp('02-AUG-12 10.45.02.222000000 AM','dd-mon-rr hh.mi.ss.ff9 pm') from dual union all
                      select to_timestamp('02-AUG-12 01.45.02.222000000 PM','dd-mon-rr hh.mi.ss.ff9 pm') from dual union all
                      select to_timestamp('29-FEB-12 01.45.02.222000000 PM','dd-mon-rr hh.mi.ss.ff9 pm') from dual
select  date1,
        case to_char(date1,'mmdd')
          when '0229' then date1 - interval '1' day
          else date1
        end + interval '1' year date1_plus_1_year
  from  sample_table
DATE1                               DATE1_PLUS_1_YEAR
02-AUG-12 01.45.02.222000000 PM     02-AUG-13 01.45.02.222000000 PM
02-AUG-12 01.45.02.222000000 PM     02-AUG-13 01.45.02.222000000 PM
02-AUG-12 10.45.02.222000000 AM     02-AUG-13 10.45.02.222000000 AM
02-AUG-12 01.45.02.222000000 PM     02-AUG-13 01.45.02.222000000 PM
29-FEB-12 01.45.02.222000000 PM     28-FEB-13 01.45.02.222000000 PM
SQL> As you can see, February 29 of leap year is converted to February 28 of next year.
SY.

Similar Messages

  • Not receiving correct results using to_timestamp and java code

    Using Linux AS3 10.1.0
    When I run the following query via ISQL, I receive results. Executing the same query via a java program returns no results. In the time range, if I change the 16:00:00 to 03:00:00, I get results VIA the JAVA CODE and ISQL. I am not receiving an error message in java or the database. If there is a problem with the java code, why do I get results when I change to 03:00:00?
    Any comments / solutions are much appreciated!
    SELECT (to_char(time_started, 'YYYY-MM-DD HH24:MI:SS')) AS dtg FROM table1 WHERE (time_started between to_timestamp('2006/04/19 16:00:00', 'YYYY/MM/DD HH24:MI:SS') and (to_timestamp('2006/04/21 19:00:00', 'YYYY/MM/DD HH24:MI:SS'))) ORDER BY time_started DESC

    Hi
    1) Is it possible that your Java and iSQL sessions are running in different timezones for some reason (eg because of a login.sql, a login trigger or something similar run by one and not the other, which could have done something like:
    ALTER SESSION SET TIME_ZONE = '-8:00';
    2) Are they TIMESTAMP, TIMESTAMP WITH TIMEZONE, or TIMESTAMP WITH LOCAL TIMEZONE? Given that you are only working down to seconds, would DATE datatype be simpler?
    3) Check the TIME_STARTED values returned and make sure they are what you expect
    4) double check that you really do have identical SQL in both cases, and that you haven't accidentally changed one of them
    HTH
    Regards Nigel

  • Doubt using CastorMapping...Urgent.......

    hi guys....
    i'm new to castor. i have to generate the xml using namespace uri with attribute like..
    <pre:MyRequest xmlns:pre="http://...." type="MyList">
    <message>
    <mymessage/>
    </message>
    </pre:MyRequest>
    code of my castor xml
    <class name="ListRequest">
    <map-to xml="MyRequest" ns-uri="http:.." ns-prefix="pre" />
    <field name="type" type="java.lang.String">
    <bind-xml name="type" node="attribute"/>
    </field>
    <field name="message" type="Wrapper">
    <bind-xml name="message" node="element"/>
    </field>
    </class>
    when i run my java coding the xml has generated like as follows..
    <pre:MyRequest type="MyList" xmlns:pre="http://...." >
    <message>
    <mymessage/>
    </message>
    </pre:MyRequest>
    what my doubt is i the attribute of type should be come after the namespace.. how to do this.. plz give me ur valuable suggestion. its need very urgent.
    thanx in adv with reg
    DJ

    hi guys....
    i'm new to castor. i have to generate the xml using namespace uri with attribute like..
    <pre:MyRequest xmlns:pre="http://...." type="MyList">
    <message>
    <mymessage/>
    </message>
    </pre:MyRequest>
    code of my castor xml
    <class name="ListRequest">
    <map-to xml="MyRequest" ns-uri="http:.." ns-prefix="pre" />
    <field name="type" type="java.lang.String">
    <bind-xml name="type" node="attribute"/>
    </field>
    <field name="message" type="Wrapper">
    <bind-xml name="message" node="element"/>
    </field>
    </class>
    when i run my java coding the xml has generated like as follows..
    <pre:MyRequest type="MyList" xmlns:pre="http://...." >
    <message>
    <mymessage/>
    </message>
    </pre:MyRequest>
    what my doubt is i the attribute of type should be come after the namespace.. how to do this.. plz give me ur valuable suggestion. its need very urgent.
    thanx in adv with reg
    DJ

  • Did you insert a value use to_timestamp()?

    Hi all,
    I met a problem:
    I used the string as "INSERT INTO TABLE_A VALUES(TO_TIMESTAMP('2012-02-15 12:21:23.23', 'YYYY-MM-DD HH24:MI:SS.FF'));COMMIT;".
    Timesten reported: TT0805: TO_TIMESTAMP has not been implemented.
    How can I use the to_timestamp() or other function?

    Hi Raul,
    TimesTen doesnt have TO_TIMESTEN function.
    The datetime functions are as follows:
    ADD_MONTHS
    EXTRACT
    MONTHS_BETWEEN
    NUMTODSINTERVAL
    NUMTOYMINTERVAL
    ROUND (Date)
    SYSDATE and GETDATE
    TIMESTAMPADD
    TIMESTAMPDIFF
    TO_DATE
    (http://docs.oracle.com/cd/E21901_01/doc/timesten.1122/e21642/function.htm#CACHGGIC)
    regards,
    Gennady

  • Doubt using Proxy

    Hi,
    I had a small doubt, I want to implement a scenario where in if i post a xml file in the specific directory i need to get that xml data in a user defined table in R/3 sytem.
    To do this can i use a proxy. By defining in SPROXY Transaction.
    Thanks in advance

    Hi,
    That's a good idea to use proxy.
    Your scenario should look like that:
    File->XI->Proxy
    Inside generated proxy just put the code which will add data to the table and handle all errors.
    Please check this blog:
    /people/prateek.shah/blog/2005/06/14/file-to-r3-via-abap-proxy
    Regards,
    Wojciech
    Reminder: please reward points for good answer

  • Doubts using NI cRIO 9012 and NI 9111..

    Hello.. i'm using NI cRIO-9012, NI-9111, NI 9234, NI 9201 and NI 9474 in a school project... i started to do some easy things like sine wave acquisition in order to be more in touch with the labview hardware and software, the software that i'm using it's the LabView 2009 Service Pack 1.
    i have acquired the sine wave with NI 9234 and NI 9201 and i couldn't find the diference between this two modules, is there any thing that i can do with one of them and couldn't do with the other? what's the main diference between them?
    i couldn't realise either how many points am i acquiring at each period (acquisition rate i think) of the wave? (would you like me to send the code?)
    from these two modules i got something, from the NI 9474 i've saw nothing yet... i was trying to generate PWM wave and i use the FPGA help wizard to generate the code, everything was fine but i couldn't get anything.
    I hoping that someone can help me..
    Thanks
    Mário Silva

    Hi Maxime,
    thanks for answering, i took a look at the links you gave me and one of them i've seen it before (cRIO Pulse Width Modulation) but i must tell you that i'm new at labview and those VI's are too much for me to carry yet =) ....
    About the engine times i've told my doubt was, should i use Single Point Continuous or Single Point Timed I/O to create PWM??
    I tried Single Point Continuous and i'll let you know the VI's i've used...I could see that by changing the values of Active Time and Period the brightness of the little led at the output port was changing too but there was nothing appening at the scope. The signal just change all to zero or all to my source signal (12V), there's no PWM oscillation.
    About the code i have some questions too, i can't understand how some subVI's are created, how are they conected with the FPGA and HOST and what are they for..
    there are some blocks that appear  when i run the FPGA Wizard that i can't find when i creating a blank project, i think that they has to do with the subVI's i told you and some dependencies too.
    I really appreciate your patience, thanks a lot.
    The best regards
    Mário Silva
    Attachments:
    Single Point Continuous PWM_fpga.vi ‏54 KB
    Single Point Continuous PWM_Host.vi ‏312 KB
    FPGA_doubt.png ‏123 KB

  • Some doubts using abap

    Dear experts,
    I have used functionmodule as RFCs to fetch data from SAP
    using java/jco.Here i realised that all work has to be done in sap itself.Java is just a platform to fetch that object and show me the data.
    However i wish to know can i use native java platform itself
    ie only  jdk installalation with jco to write reports and fetch output just as i work in se38.
    Is there any separate java library for this where i can use joins ,pass querys just as i do in normal abap.
    Am i close to netweaver ,these questions are alway budding in my mind
    Regards,
    Aditya Sharma

    This is an area that I've gone changed my view on over the years. 
    When Netweaver was first introduced with it's dual stack (ABAP and Java) I was frustraited that you couldn't access the ABAP DB Schema from the Java side of the stack.  The architecture (which you can get aroudn if you really want to, but I wouldn't reccommend it) forces you to use either RFCs or WebService calls to access data on the ABAP stack from the Java stack.
    As time has gone on though I have realized that this is actually a good setup from an architecture perspective because it forces you into a seperation of concerns where your ABAP modules are implimenting a buisenss object layer around the data in the ERP system.  Additionally if you are building a composite application that combines SAP functionality with that of services provided by other applications then this actaully keeps some architectural purity to it becuase the SAP ABAP system is treated the same as any other system that it is utilizing. 
    So my recomendation would be to stick with service calls accross the stacks and not direct DB access.  In the end you'll have applications that are architected better.
    ~Ian

  • Doubt using thr Read Tag .vi

    I,m having some difficulty trying to understand the following:
    The manuals I´ve read tell that to use the Read Tag.vi it´s not necessary to previously start the Tag Engine using the Engine Launch.vi.
    But, when I try to read the value of a discrete tag using the Read Tag.vi, the error output turns on. Because of this I decided to start the Tag Engine usung the Engine Launch.vi before reading the tag but, to my dismay, the error persisted.
    Seeing this happen make me start to think that the problem was that the engine hasn´t yet initialized when the Read Tag.vi ran; so, I decided to wait an certain amount of time - in this case, 4000 ms would suffice - before reading the tag value and, with this, no error occurred. Could anyone pelease
    tell me if my assumption is correct ? If not, why is this happening ?
    PS :
    It´s necessary to wait the time interval just the first time the tag is read. Afterward, no errors occur.

    Hi Giovani,
    I believe you are correct in your work so far.
    The tag engine takes some time to start. I seem to remeber an applicatin with 6000 tags taking a minute or more to start up.
    You can use the "Get Engine Status.vi" to determine when the engine is up and running. This will work more reliably that a fixed wait time.
    So,
    You are correct!
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Doubt using Group Layout

    Hello everybody, i have been using GroupLayout and I encountered a little problem that i could not solve. I would like to see if any of you are able to give me a hand with this.
    I try to add two components to a container (one over the other in Y AXE) , using the following code
    layout.setHorizontalGroup(layout.createSequentialGroup()
         .add(layout.createParallelGroup((GroupLayout.LEADING)))
              .add(tbToolPanel)
              .add(canvas.getGeneralPanel())
    layout.setVerticalGroup(layout.createSequentialGroup()
         .add(tbToolPanel)
         .add(canvas.getGeneralPanel())
    );The problem is that it just add the canvas.getGeneralPanel() component, the other does not appear, unless i comment the .add(canvas.getGeneralPanel()) lines.
    Do you have any idea of why this happens?
    Any suggestion would be helpfull.
    Thanks!

    GroupLayout is mostly used by IDE's so they can use a single layout manager to manage all components on a frame.
    For us humans its easier to mix and match layout managers to get the desired layout.
    I try to add two components to a container (one over the other in Y AXE)Sounds like a BoxLayout would be more suitable.
    If you need further help then you need to create a [Short, Self Contained, Compilable and Executable, Example Program (SSCCE)|http://homepage1.nifty.com/algafield/sscce.html], that demonstrates the incorrect behaviour.

  • Doubt using log4j

    Hi there,
    I'm using jboss3.2.5 to access my java applications.
    I would like to make a different log directory to each application. Is this possible using log4j ? (i've never tried it)
    If so, how do i set the log4j properties for each application to use ?
    Thanks,

    Have you tried setting the file parameter to point to a different location?
      <appender name="myAppender" class="org.apache.log4j.DailyRollingFileAppender">
        <param name="DatePattern"    value="yyyy-MM-dd"/>
        <param name="File"           value="./logs/myLogName.log" />
        <param name="Append"         value="false" />
        <layout class="org.apache.log4j.PatternLayout">
          <param name="ConversionPattern" value="%-5p : %d{yyyy/MM/dd : HH:mm:ss} : %l : %x : %m%n"/>
        </layout>
      </appender>

  • Doubt using clone

    Hi
    when the Object class implements the clone(), why is that we need to explicitly extend the Cloneable intetface when the method is already implemented.

    The reason is that the clone() method is protected, so you cannot simply call your superclass's clone method. You have to create your own and declare that you implement Cloneable. The reason is that the super class's clone method may not (and in fact, probably is not) suitable for your class. So in their infinite wisdom, the creators of Java make you implement your own clone method.

  • 1 Urgent doubt using filestream from JBuyout class!1!1!

    C-Web. No surprise I guess. Going where? Pistons? Suns?

    C-Web. No surprise I guess. Going where? Pistons?Suns?
    Hadn't heard this, cotton.
    http://sports.espn.go.com/nba/news/story?id=2726276
    Suns? Good for Webber, but why do they need him?
    Great team already.Yes but more inside presence never hurt. This is more my hope
    >
    Pistons? Help to replace Big Ben might be nice.
    http://sports.espn.go.com/nba/news/story?id=2727137

  • Bought iTunes Gift cards and lost them in the train earlier today. I send an email using Express lane, have just been informed that Apple cannot assist me in deactivating these cards before someone else(a thief no doubt) uses them. How can I solve this?

    I am shocked Apple is not taking this seriously. I have receipt and my bank statement to prove the transaction took place. £250 (£50 x 5) is what I will be losing.

    iTunes gift cards, as is the case with many gift cards, are like cash; if you lose them, they're gone and cannot be refunded, nor can Apple deactivate the cards; they have no way of doing so. Sorry, but you're just out that money.
    Regards.

  • Importing timestamp columns appears to use to_date instead of to_timestamp

    I'm trying to import data (using the latest version 1.5.4 with Patch 2 applied) to an Oracle 10g database that contains timestamp columns. The input data has times with fractional (millisecond) values The data was exported using SQL Developer from a Sybase database and the timestamp format in the Excel (xls) file is YYYY-MM-DD HH24:MI:SS.FF3. When I specify this format for the TIMESTAMP columns on the import screens, the importer generates an insert statement like this:
    INSERT INTO A (TMS) VALUES (to_date('2008-12-049 12:12:39.967', 'YYYY-MM-DD HH24:MI:SS.FF3'));
    This command fails to execute with this error:
    Error report:
    SQL Error: ORA-01821: date format not recognized
    01821. 00000 - "date format not recognized"
    *Cause:   
    *Action:
    I found that if to_timestamp is used instead of to_date, there is no issue inserting the row with the correct time precision. The question I have is why isn't SQL Developer using to_timestamp for importing a TIMESTAMP column, and should it?
    Any advise woudl be appreciated.
    Thanks

    In 1.5.4 I see a bug where the "Format" field doesn't show up in the page in the import wizard, preventing the user from entering a mask when the column type is TIMESTAMP. This has been fixed in the code line under development and should be available when 2.1 gets released.
    To give you a bit more detail on the confusing DATE/TIMESTAMP behaviour...
    SQL Developer misrepresenting date as timestamp and vice versa stems from the behaviour of the Oracle JDBC driver. Following are the details I obtained from the JDBC team when I raised a bug("WRONG VALUE RETURNED FOR GETCOLUMNTYPE FOR DATE COLUMN ") on them:-
    oracle.jdbc.mapDateToTimestamp is by default set
    to true to indicate reporting DATE column as TIMESTAMP type. To turn off, pass
    -Doracle.jdbc.mapDateToTimestamp=false" at the command line.
    To effect this option in SQL Developer, you can add an AddVMOption -Doracle.jdbc.mapDateToTimestamp=false
    A bit more history on the option:
    8i and older Oracle databases did not support SQL TIMESTAMP, however Oracle
    DATE contains a time component, which is an extension to the SQL standard. In
    order to correctly handle the time component of Oracle DATE the 8i and
    earlier drivers mapped Oracle DATE to java.sql.Timestamp. This preserved the
    time component.
    Oracle database 9.0.1 included support for SQL TIMESTAMP. In the process of
    implementing support for SQL TIMESTAMP we changed the 9i JDBC driver to map
    Oracle DATE to java.sql.Date. This was an incorrect decision since it
    truncates the time component of Oracle DATE. There was also a backwards
    compatibility problem trying to write java.sql.Timestamps to 8i databases.
    These are separate problems but we "fixed" both under the control of a single
    flag, V8Compatible. This flag was introduced in a 9.2 patch set.
    By default the flag is false. When it is set to false the driver maps Oracle
    DATE to java.sql.Date, losing the time component and it writes
    java.sql.Timestamps to the database as SQL TIMESTAMPS. When the flag is set
    to true the driver maps Oracle DATE to java.sql.Timestamp and writes
    java.sql.Timestamps to the database as Oracle DATEs.
    In 11.1 the V8Compatible flag was deprecated because it controlled Database
    8i compatibility which is no longer supported. The additional behavior it
    controlled, how SQL DATEs are handled, is controlled by a new flag,
    mapDateToTimestamp. In 11.1 setting V8Compatible will just set
    mapDateToTimestamp. This new flag only controls how SQL DATEs are
    represented, nothing more. This flag will be supported for the foreseeable
    future.
    Finally, the default value for V8Compatible is false in 9i and 10g. This
    means that by default the drivers incorrectly map SQL DATEs to java.sql.Date.
    In 11.1 the default value of mapDateToTimestamp is true which means that by
    default the drivers will correctly map SQL DATEs to java.sql.Timestamp
    retaining the time information. Any customer that is currently setting
    V8Compatible = true in order to get the DATE to Timestamp mapping will get
    that behavior by default in 11.1. Any customer that wants the incorrect but
    10g compatible DATE to java.sql.Date mapping can get that by setting
    mapDateToTimestamp = false in 11.1.
    About the only way to see the difference between mapDateToTimestamp settings
    is to call getObject on a DATE column. If mapDateToTimestamp is true, the
    default setting, the result will be a java.sql.Timestamp. If
    mapDateToTimestamp is false, then getObject on a DATE column will return a
    java.sql.Date.
    HTH
    Edited by: vasan_kps on Jun 12, 2009 2:01 PM

  • Can I use airport express to create a local wireless network that my apple tv can connect to for AirPlay/mirroring in student halls/dorm without Internet connection

    Hi I was wondering :
    Would I be able to make a local wireless network using airport express that my apple tv can connect to which in turn is connected to a projector with hdmi in so that I can mirror/AirPlay from iPhone pad and mac

    will the Airport Express allow you to log onto a hotel wireless network, and broadcast a secure wireless network in your room for your wireless devices, like the Ipad, Iphone, etc.?
    The bottom line with a single AirPort Express is no.
    The AirPort Express can only "extend" a wireless network when the network is being provided by another Apple router.
    As you might imagine, it is extremely unlikely that that the hotel network....which no doubt uses professional wireless access points provided by a manufacturer of commercial systems.....would be compatible with an AirPort Express.
    In many years of travel domestically and internationally, I cannot recall a time when a single AirPort Express would "extend" the signal provided by a hotel's wireless network.
    However, if you had two AirPort Express devices handy, you might be able to configure one to "join" the hotel network and provide an Ethernet signal to the second AirPort Express, which would be configured to "create" your own "private"  wireless network.

Maybe you are looking for

  • Audio Books and ipods

    Hello All Recently my wife has lost some vision in her eyes and can no longer find it easy to read books. My idea is to buy an ipod (no idea which) and download the cd audio book onto the ipod so she can listen. Q. Will whole cd audio books fit on an

  • Importing subtitles from speech recognition

    Hi I have been using CS4 and have used the speech translation tool from an mpeg file . Is there any way of importing the speech transcript into subtitles and keeping the timings for the speech. I know i can import the text into encore but i need a ve

  • Determining default application by extension

    Hello everyone, Desktop class is a beautiful step forward in Java. It can launch applications in various modes, depending on the document file type, so that: Desktop.getDesktop().open(new File("test.odt"));will open the test.odt document in an OpenOf

  • CUCM 6.1 - Phone Directory - how to add second number?

    Does it possible to add another directory like corporate directory, or how can we add people's second number to corporate directory? thanks

  • A thought - Syncing for Front Row

    I have 2 AppleTVs, several iPods, 3 Macs and 2 MacBooks in use around my house. We use Front Row on the 2 MacBooks a lot. Unfortunately we don't keep our Movies and TV Shows on the MacBook HDDs. They use shared libraries from two different iMac deskt