Extract time from sysdate or some other?

Dear all,
I want to extract the Hour as a number from sysdate. Plz guide me.
Ex: SELECT EXTRACT (YEAR FROM SYSDATE) FROM DUAL;
I want like SELECT EXTRACT (Hour FROM SYSDATE) FROM DUAL;
Thanks in Advance..

you can use to_char function
select to_char(sysdate, 'hh24') from dualor use a timestamp with extract function
select systimestamp, extract(HOUR from systimestamp) from dual

Similar Messages

  • How to subtract Time from Sysdate

    Hello,
    I want to subtract time from sysdate and get the sysdate with time.
    Example : = (Sysdate with time)03-mar-2002 16:40:55 - 8 (hours). The result should be like :03-mar-2002 08:40:55
    How to write a query for this?.
    Please let me know as soon as possible.
    Thanks,
    Ravi.

    Hi Ravi...
    SYSDATE includes time, TRUNC(SYSDATE) does not include time.
    If you subtract these two, you'll get a positive number of 1.00 or less which is the fraction of a day. For instance high noon would have a fraction of 0.50000. 12:01 p.m. would be 0.50000 + (1/(24*60)), or 0.50069444....
    If you want to set the clock back, by calculating a "date" that is 8 hours less than the SYSDATE, then SYSDATE - (8/24) will do that. This will work even if SYSDATE was something like 2 a.m., because it will then set it to 6 p.m. of the day before the day in SYSDATE.
    If you want to set a "date" to a specific time on the day of SYSDATE, then calculate the fraction for that time and add it to the TRUNC(SYSDATE). High noon would be TRUNC(SYSDATE) + 0.5.
    SELECT TO_CHAR(TRUNC(SYSDATE)+0.5,'DD-MON-YY HH:MI:SS am') AS NOON FROM DUAL;Hope this helps...
    Larry Johnson

  • Select extract(month from sysdate)+6 = returns 13 and not 1(jan)

    Hi
    I am using the following query to get the month 6 months from now.
    select extract(month from sysdate)+6
    from dualHow can I say that the month should be 6 months from todays month? It worked all these days because this month + 6 was always a valid month. Now it returns 13.

    When I run the following, I get '1'. I am expecting '01'. What am I doing wrong here?
    SELECT substr(lpad(to_number(to_char(ADD_MONTHS(SYSDATE, 6),'MM')),2),1,2) FROM DUAL;
    I need number - so using to_number. I need to extract the month, so using to_char. If someone could help me get 2 digits for the month and simplify the query if possible - would be great.
    The table has month and date stored as number (bad idea I know but thats how it is). Now for January 31, it is stored as 131. For 15 Feb it is 215. What I need is give me records where the month is 6 months from now. Something like:
    to_number(substr(lpad(tbl1.monthdt, 4, '0'), 1, 2)) in
    substr(lpad(to_number(to_char(ADD_MONTHS(SYSDATE, 6),'MM')),2),1,2)Message was edited by:
    bpel

  • Restore the backup from tape to some other server

    Dear All,
    I need to restore the backup from tape to some other server.PLease suggest the command and setp to do that.
    Regards,
    Kumar

    Hi,
    I went through as per your action plan it is giving below error I found a solution on meta doc id 559190.1 but i am not able to understant how to start observiced as it is mentioned in the doc id.
    allocated channel: t1
    channel t1: sid=2386 devtype=SBT_TAPE
    channel t1: Data Protection for Oracle: version 5.4.1.0
    Starting restore at 09-MAY-10
    channel t1: looking for autobackup on day: 20100509
    released channel: t1
    RMAN-00571: ===========================================================
    RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
    RMAN-00571: ===========================================================
    RMAN-03002: failure of restore command at 05/09/2010 11:57:01
    ORA-27191: sbtinfo2 returned error
    Additional information: 2
    RMAN>
    Thanks,

  • HT4914 My music is stored on an external hard drive. All music that I buy, whether from itunes or some other provider, automatically gets loaded onto my external drive. There is some music on my computer drive as well. Will match work in this circumstance

    My music is stored on an external hard drive. All music that I buy, whether from itunes or some other provider, automatically gets loaded onto my external drive. There is some music on my computer drive as well. Will match work in this circumstance?

    I followed all the instructions for consolidating my music into one folder on my external hard drive. (I'm struggling with this because my ext HD was renamed when I synched my iPod shuffle last night. The "E:" drive has now become the "F:" drive and all my songs have those dreaded exclamation points next to them. Exploring my computer, I found "My music" folders in two place on my C: drive and one place on my external hard drive... and the song list in each place is different.
    Argh.
    So... following the directions in the article reference here, I attempted to consolidate all of my songs into one folder on my external hard drive.
    But.. I checked the song list when the "consolidation" was complete... and MANY songs are missing. They're still on the C: drive, but don't appear to have been copied to the new folder on the ext HD.
    I would appreciate any suggestions.
    Thanks so much!
    Edit: I tried to reassign the ext. HD a permanent letter, but my Control panel does not appear to offer the option of Administrative tools. Is there an easy way to get to this, as this seems to be the root of the problem?
    Thanks.
    Message was edited by: hbdivegirl

  • Extracting time from date and adding it to another date.

    Dear All,
    The values of two fields in my table are as follows:
    n_date n_time
    12/7/2007 1/1/1970 5:50:23 PM
    Both of these fields are of date data type.
    How can i add the time from n_time to n_date so that n_date will reflect a date with time added?
    The problem is that i want to sort on n_date and i am not getting result when two dates are having same values for n_date but different for n_time.
    How can i create a new expression for sorting these values?
    Thanks in advance.
    Regards,
    Sameer

    Hi,
    Check this.
    with data as
    ( select to_date('12/7/2007','dd/mm/yyyy') as ndate, to_date('1/1/1970 5:50:23','dd/mm/yyyy hh24:mi:ss') ntime from dual)
    select ndate + (ntime - trunc(ntime)) from data
    Regards
    RK

  • Select time from sysdate

    Hi Experts,
    I have to concatenate a date(not sysdate) with the system time and store it in a column having datatype as DATE...
    So I tried like this....
       SELECT
                  TO_CHAR (C_DATE, 'DD-MON-YYYY')
               || ' '
               || TO_CHAR (SYSDATE, 'HH:MI:SS PM')
        FROM   DUAL;
    But while inserting the output of the above query in my table it throws error like this...
    ORA-01830: date format picture ends before converting entire input string
    Is there any possibility to achieve this....
    Thanks in advance.

    Hi,
    The || operator produces a string.  Don't use a string where a DATE is expected; use a DATE instead.  For example
    INSERT INTO  new_table (c_date)
    SELECT  TRUNC (SYSDATE) + (c_date - TRUNC (c_date))
    FROM    old_table;

  • Extract data from xml column to other table

    Hi
    I have a table with clob column, inside have a xml, How can I to extract data inside column
    Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
    PL/SQL Release 9.2.0.8.0 - Production
    CORE     9.2.0.8.0     Production
    TNS for IBM/AIX RISC System/6000: Version 9.2.0.8.0 - Production
    NLSRTL Version 9.2.0.8.0 - Production

    thank you
    I have a table
    SQL> desc xml_documents;
    Name      Type          Nullable Default Comments
    DOCNAME   VARCHAR2(200)                          
    XMLDOC    CLOB          Y                        
    TIMESTAMP DATE          Y                         inside XMLDOC column there is only a record below
    <!-- claim77804.xml -->
    <Claim>
    <ClaimId>77804</ClaimId>
    <Policy>12345</Policy>
    <Settlements>
    <Payment Approver="JCOX">1000</Payment>
    <Payment Approver="PSMITH">1850</Payment>
    </Settlements>
    <DamageReport>
    The insured's <Vehicle Make="Volks">Beetle</Vehicle>
    broke through the guard rail and plummeted into a ravine.
    The cause was determined to be <Cause>faulty brakes</Cause>.
    Amazingly there were no casualties.
    </DamageReport>
    </Claim>I tried to use example from : http://www.oracle-base.com/articles/9i/xmlsequence.php
    SELECT extract(value(d), '//POLICY/text()').getStringVal() AS empno
    FROM    xml_documents x,
           table(xmlsequence(extract(x.xmldoc, '/ROWSET/Claim'))) d;But no work, show me error
    ORA-00932: inconsistent datatypes: expected - got -

  • Have you noticed that firefox crashes when you try to switch from english to some other language (ie greek)?

    every time i try to switch language in my keyboard from english to greek ("alt+shift" or task bar button) firefox crashes. any solutions?

    We're sorry to hear that Firefox is crashing. In order to assist you better, please follow the steps below to provide us crash IDs to help us learn more about your crash.
    #Enter ''about:crashes'' in the Firefox address bar and press Enter. A Submitted Crash Reports list will appear, similar to the one shown below.
    #Copy the '''5''' most recent Report IDs that start with '''bp-''' and then go back to your forum question and paste that into the "Post a Reply" box. (Please don't take a screenshot of your crashes, just copy and paste the ID's. The below image is just an example of what your Firefox screen should look like)
    [[Image:aboutcrashesFx29|width=520]]
    <br><br>
    Thank you for your help!
    More information and further troubleshooting steps can be found in the [[Firefox crashes - Troubleshoot, prevent and get help fixing crashes]] article.

  • Extract Time from date and Time and Need XLMOD Funtion to find the Difference between Two Time.

    X6 = "1/5/15 5:16 AM" & NOW ....................difference by Only Time
    not date
    X6 date and Time will be changing, Its not Constant
                Dim myDateTime As DateTime = X6
                Dim myDate As String = myDateTime.ToString("dd/MM/yy")
                Dim myTime As String = myDateTime.ToString("hh:mm tt")
                Dim myDateTime1 As DateTime = Now
                Dim myDate1 As String = myDateTime1.ToString("dd/MM/yy")
                Dim myTime1 As String = myDateTime1.ToString("hh:mm tt")
    Need to use this function to find the Difference between Two Time. due to 12:00 AM isuue
    Function XLMod(a, b)
        ' This replicates the Excel MOD function
        XLMod = a - b * Int(a / b)
    End Function
    Output Required
     dim dd  = XLMod(myTime - myTime1)
    Problem is myTime & myTime1 is String Need to convert them into Time, Later use XLMOD Funtion.

    Induhar,
    As an addendum to this, I thought I'd add this in also: If you have two valid DateTime objects you might consider using a class which I put together a few years ago
    shown on a page of my website here.
    To use it, just instantiate with two DateTime objects (order doesn't matter, it'll figure it out) and you'll then have access to the public properties. For this example, I'm just showing the .ToString method:
    Option Strict On
    Option Explicit On
    Option Infer Off
    Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) _
    Handles MyBase.Load
    Dim date1 As DateTime = Now
    Dim date2 As DateTime = #1/1/1970 2:35:00 PM#
    Dim howOld As New Age(date1, date2)
    MessageBox.Show(howOld.ToString, "Age")
    Stop
    End Sub
    End Class
    I hope that helps, if not now then maybe at some point in the future. :)
    Still lost in code, just at a little higher level.
      Thanx frank, can use this in Future....

  • Movement Type Change From 321 to Some other In Stock Posting (Insp Type 05)

    Hi,
        While doing the stock Posting From quality to Unrest - Automatic 321 Movment type is happening
        But my client neads to identify how many qty from custmer return is passed to unrestricted from       
        quality.
       i have problem in identify since 01 and 04 and also 05 all are having the same mvt since it is automatic
    Can it be possible to chnage the mvt for the particular Inspection type 05.
    kindly give me is there any way to solve this issue.
    Regards
    jai

    Dear jaikumar
    No need of changing movement type for the same. You have too many options to get this fugure
    You can use Tcode se16, se16n and in the table QALS you will be able to know the quantity posted to unrestricted by selecting 05 inspection and from to date in input for the table view
    else go to the standard report . Tcode MCXC, MCXI you will get the report based on inspection type and period
    Regards
    gajesh

  • Change default audio volume from 75 to some other value

    We are running Solaris with CDE. The sound volume is too high when
    we reboot the machine. We can change it with
    /usr/dt/share/bin/sdtaudio or /usr/openwin/bin/audiocontrol with a GUI
    slider down to about 20. The default is 75. This works fine until we
    reboot the machine, and then it goes back to 75, which is too high. I
    can certainly add a boot script to change the value but I don't know
    what to use. Things like
    audioplay -v 20
    just don't persist across reboots but I don't think this is the proper
    method to change it anyway.
    We are actually running Solaris 8 but I'm hoping this isn't an inherent limitation.
    TIA.

    raj,
    there is no material number in the PO, it is given as SERVICE material group and given only text.
    I observed once I enter the Unit of Measure EA the taxcode is coming and also after providing the purchasing org, purchasing group and company code.
    Thanks for your time.
    Sreeni

  • Appletv & Time capsule question and some others.

    Hello
    My ATV is pretty much full now and so today I have taken delivery of a Time Capsule (1TB).
    Question 1: Lets assume the TC is half full this time next year. This makes it much bigger than the laptop itunes is on. How do I make it leave stuff on the ATV/TC but not synch it over to itunes?
    Question 2: My itunes crashes everytime it tries to synch with ATV. Another thread on here suggests that if you have a large amount of data that needs synching (in my case about 15 new tv episodes and a film, so a fair bit) then it works better if hardwired. Must I disable the wireless if I'm hardwiring it? If so, how? As it is currently, each time I connect up the laptop to the ATV with the ethernet cable it makes it all go incredibly wrong.
    Thanks for your help.

    Welcome to the  Discussion Forums
    Carrera4t wrote:
    Question 1: Lets assume the TC is half full this time next year. This makes it much bigger than the laptop itunes is on. How do I make it leave stuff on the ATV/TC but not synch it over to itunes?
    Follow the instructions in this article to move your content, it should do just what you want once you have done this.
    http://support.apple.com/kb/HT1364
    Question 2: My itunes crashes everytime it tries to synch with ATV. Another thread on here suggests that if you have a large amount of data that needs synching (in my case about 15 new tv episodes and a film, so a fair bit) then it works better if hardwired. Must I disable the wireless if I'm hardwiring it? If so, how? As it is currently, each time I connect up the laptop to the ATV with the ethernet cable it makes it all go incredibly wrong.
    iTunes crashing could indicate a problem with itunes, your network or your OS.
    Your wifi settings are disabled on the Apple tv when an ethernet connector is plugged into it.
    If you are connecting an ethernet cable directly between your PC and the Apple tv, you should be using a cross-over cable.
    Message was edited by: Winston Churchill

  • Suddenly i cannot load videos from you tube and some other locations, although I can load then using CHROME

    The problem is that all of a sudden, I cannot load and see videos from youtube and some other sites.
    When I ask to see something from youtube for example, the appropriate page opens, and in the place that the video was supposed to be loaded, I see a black screen and nothing happens.
    I scanned the computer and found nothing.
    I uninstalled firefox and installed it again.
    The problem stays.
    I browsed using CHROME and I have no problem. i can see everything perfectly.
    This happened suddenly today.

    Could they be viewed ... and used ... by QuickTime Player?
    Installing the Perian codec component package will normally allow FLV file containers to be played in QT players. However, it might be more helpful here if you could provide a specific YouTube URL (and resolution if applicable) of interest to check out. While I previously indicated content was typically converted to FLV, MP4 files may also be used and content may compressed as H.264/AAC in either container which, of course, should already be QT compatible without additional support.
    Could anything be done about improving video quality?
    That depends. If the file you are interested in is available in multiple resolutions, then downloading the highest available resolution would provide the best starting point for iMovie editing. If compressed content is already in an iMovie compatible compression format, then it might be possible to copy the content to an iMovie compatible file container (if not already in one) and thus avoid transcoding the data before import to iMovie. However, you still have the potential for some visual quality loss after editing when you export the finished project from iMovie.

  • How to get the difference in years from sysdate

    Hi all,
    I want to display years from 2005 to sysdate. I have tried this, but it is giving same SYSDATEs year 6 times.
    SELECT  EXTRACT(YEAR FROM SYSDATE + LEVEL -1) FROM DUAL CONNECT BY LEVEL < TRUNC(MONTHS_BETWEEN (SYSDATE,TO_DATE('2005','YYYY'))/12)
    Thanks in advance,
    Pal

    Hi dude,
    Try this code
    DECLARE
       from_dt   DATE          := TO_DATE ('01/01/2009', 'mm/dd/yyyy');
       to_dt     DATE
          := TO_DATE (TO_CHAR (SYSDATE, 'mm/dd/yyyy') /*'01/01/2010'*/,
                      'mm/dd/yyyy'
       x         VARCHAR2 (30);
    BEGIN
       WHILE NOT from_dt > to_dt
       LOOP
          IF TO_DATE (x, 'dd-mon-yyyy') >= to_dt
          THEN
             DBMS_OUTPUT.put_line ('hello');
             EXIT;
          ELSE
             DBMS_OUTPUT.put_line ('FROM DATE ==>' || from_dt);
             x := from_dt + 1;
             IF TO_DATE (x, 'DD-MON-YYYY') > to_dt
             THEN
                DBMS_OUTPUT.put_line ('Exit Now');
             ELSE
                DBMS_OUTPUT.put_line ('Sundays -->' || x);
             END IF;
          END IF;
          from_dt := from_dt + 1;
       END LOOP;
    END;Regards,
    N.Senthil.

Maybe you are looking for