Extracting 24 hour timestramp from sysdate

Hi All,
I have some 24 hour times stored as strings in a table eg 16:00, 18:30 , 04:00 ect
I'm trying to extract the 24 timestamp from SYSDATE so that I can do a comparision such as:
IF (just need timestamp from sysdate in 24 hour format here) > TO_DATE(r.wave_finish_time,'HH24:MI') THEN...
ANy ideas on how to extract the timestamp from sysdate in 24 hour format?
Cheers in advance!
Regards
Sat

This will give you an idea (apart from the suggestions already offered).
If not, let us know.
SQL> with some_time_strings as (
  2  select '01:00' my_time from dual union all
  3  select '02:00' from dual union all
  4  select '03:00' from dual union all
  5  select '04:00' from dual union all
  6  select '05:00' from dual union all
  7  select '06:00' from dual union all
  8  select '07:00' from dual union all
  9  select '08:00' from dual union all
10  select '09:00' from dual union all
11  select '10:00' from dual union all
12  select '11:00' from dual union all
13  select '12:00' from dual union all
14  select '13:00' from dual union all
15  select '14:00' from dual union all
16  select '15:00' from dual
17  )
18  select *
19  from   some_time_strings
20  where  my_time > to_char(to_date('01-01-2009 04:50', 'dd-mm-yyyy hh24:mi'), 'hh24:mi');
05:00
06:00
07:00
08:00
09:00
10:00
11:00
12:00
13:00
14:00
15:00
11 rijen zijn geselecteerd.Explanation in short:
to_char(to_date('01-01-2009 04:50', 'dd-mm-yyyy hh24:mi'), 'hh24:mi');
means
=> to_date('01-01-2009 04:50', 'dd-mm-yyyy hh24:mi') = the date part, could also be sysdate or any DATE
=> to_char( the date part, 'hh24:mi'); = the VARCHAR2 FORMAT part, you really need to use that, since your 'time' is in fact a string.
Edited by: hoek on Apr 17, 2009 6:51 PM added some extra words, because of the weather

Similar Messages

  • 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

  • BI- Extract Hour:Min from date and get Avg

    Hi there,
    am working on BI answer and trying to get the average of the working hours of the departments. The Working Hrs column is Date format in the Database. And I managed with Forum help to Extract the Hours from this column and do the average through the BMM in the RPD on the Fact table as following:
    EXTRACT( HOUR FROM "Ain_Access"."Fact_Access"."Working Hours")
    Now on the BI Answer results I have 8 instead of 08:57.
    But what I need is to Extract the Hour and the minuets and get their AVG.
    Appreciate your help,

    Averaging column with date/time format in BI Answer
    this expression will work:
    (60 * EXTRACT( HOUR FROM "Ain_Access"."Fact_Access"."AVG Working Hours" ) + EXTRACT( MINUTE FROM "Ain_Access"."Fact_Access"."AVG Working Hours" )) / 60
    but only if this "AVG Working Hours" is DATE type.... and this look like strange name fore DATE? "AVG" is average, aren't?
    Arent u need to use "Working Hours" instead of "AVG Working Hours" ?
    like this:
    (60 * EXTRACT( HOUR FROM "Ain_Access"."Fact_Access"."Working Hours" ) + EXTRACT( MINUTE FROM "Ain_Access"."Fact_Access"."Working Hours" )) / 60
    all best
    phenix

  • 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

  • How do I get the hour (24 hour format) from a stored Time value

    I have a field called start_time in a mysql database and all I need to do but unable to do so far is extract the hour in 24 hour format (no leading zeros) from this field.  I have tried all the date functions including date('G'), getdate and start_time[hours] array.
    I keep getting either todays date & time, or just he first digit in the hour.
    The following is the closest it has come to working but this is the on ethat is return just the first digit of the hour if there is two digits in the 24 hour format (ex:  2 pm = 14, it returns oly the 1)
    <?php
    $start_time = $row['start_time'];
    $hour = $start_time[hours];
    ?>
    PLEASE HELP !  I have spent too much time on such a menial task.  I think part of my problem is I am running PHP 4.
    Thanks in advance,
    Marcus

    Thanks for the response David:
    Do you mean like the following ?  I don't seem to get a value
    <?php
         mysql_select_db($dbname,$link_id);
          $lookup = "SELECT * FROM $tbl";
          $result = mysql_query($lookup);
              while ($row = mysql_fetch_array($result))
                    $query = "SELECT HOUR(start_time) AS start_hour FROM $tbl";
                    $rslt = mysql_query($query);
                    $hour = $row['start_hour'];                  //  I tried using $rslt['start_hour']; as well and that did not work either
                   echo $hour;
    ?>
    I'm sure its something elemtary I'm missing now.
    Any help is always appreciated David.
    Marcus

  • How to Get Millisec from Sysdate

    Hello all
    How to get millisec from sysdate.
    Pls let me know da query ..

    You can't get milliseconds from SYSDATE. In 9i and upwards you can get them from a timestamp, whether it be from the built-in functions SYSTIMESTAMP and LOCALTIMESTAMP or a timestamp column/variable of your own.
    Unfortunately, Oracle only supplies the means to extract seconds, but fortunately, this includes the millilseconds, which are easy enough to get to as the following demonstrates:-
    SQL> select extract(second from localtimestamp) from dual;
    EXTRACT(SECONDFROMLOCALTIMESTAMP)
                   42.765535
    SQL> select mod(extract(second from systimestamp),1) from dual;
    MOD(EXTRACT(SECONDFROMSYSTIMESTAMP),1)
                          .181223Regards
    Adrian

  • TIME_MANAGER_INFO 1 hour earlier than SYSDATE?

    When one of our processes fails and places the message back on the queue to be retried in 5 minutes time the TIME_MANAGER_INFO is 1 hour + the delay time less than SYSDATE in the database.
    For example, if our message fails at 11am and the delay period is 5 minutes the TIME_MANAGER_INFO is being set to 10:05am when I would have thought it would be set to 11:05am. I'm guessing that wherever the Advanced Queue is getting its time from hasn't been adjusted for daylight savings but where is this set/managed so I can get it in sync with SYSDATE.
    Where is the Advanced Queue getting its time from?

    Just in case anyone else comes across this, we had a bug where the queue state was staying at 1 and was never being reset to 0 once it reached its delay time. In order to "fix" this until Oracle releases a patch that works we wrote our own procedure that would compare the TIME_MANAGER_INFO value with SYSDATE and if it was earlier than sysdate then we set the state to 0 so it would be picked up by the dequeue. Easy. Except that because of the timezone issue the TIME_MANAGER_INFO value was immediately set to 1 hour earlier than SYSDATE so we always set the state to 0 regardless of its delay period. So, we are looking at using the TIMEZONE value in the system.aq$_queue_tables to determine which timezone the queue is using and compare it to the databases timezone to see if we should change the TIME_MANAGER_INFO to something different. At least, that's what we'll probably do.
    select time_manager_info,
    cast( from_tz( time_manager_info, (select timezone from system.aq$_queue_tables where name = 'MY_QUEUE$TAB')) at time zone (select sessiontimezone from dual) as date) t
    from MY_QUEUE$tab qt

  • 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

  • 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.

  • HT2479 I'm trying to extract a photo clip from my video.  How do I do that?

    I just took a video of my daughter's new wine and cheese shop.  She loved it and wanted a picture of her that is in the movie.  Can I extract a photo clip from the movie?  I can't figure out how to do it and would love some help.  Thanks.

    Or just play back in full screen and pause the video on the section you want and take a screen shot(Shift CMD + 3).
    Another thing you can do is Export using Quicktime from the Share menu and change the Export setting to Movie to Image Sequence. Make sure you export into a folder as you will get approx 30 images for every second of video you export. I would recommend creating a new project and just adding a couple seconds of the video clip around the spot that has the image you want then export Movie to Image Sequence (into a folder).

  • I want to automatically extract my iphone-videos from the iPhoto library since I have way over 25 000 objects in there. Afterwards I would like to import them into iMovie. Anyone having an idea?

    Dear all,
    I want to automatically extract my iphone-videos from the iPhoto library since I have way over 25 000 objects in there. Afterwards I would like to import them into iMovie. Anyone having an idea? Or is there no possibility to do so?
    Thanks in advace
    Andreas

    File -> New Smart Abum
    Photo -> Is -> Movie
    and export those:
    This User Tip
    https://discussions.apple.com/docs/DOC-4921
    has details of the options in the Export dialogue.

  • My Iphone was sync with Itunes on a computer then this computer broke down and i purchased another one. I was able to extract all the data from the old one. now how can i sync my phone with the new tunes without loosing any data?

    My Iphone was sync with Itunes on a computer then this computer broke down and i purchased another one. I was able to extract all the data from the old one. now how can i sync my phone with the new tunes without loosing any data?

    Yes, windows to Mac too.
    iTunes: How to move [or copy] your music [library] to a new computer [or another drive] - http://support.apple.com/kb/HT4527
    Quick answer if you use iTunes' default preferences settings:  Copy the entire iTunes folder (and in doing so all its subfolders and files) intact to the other drive.  Open iTunes and immediately hold down the Option (alt) key (shift on Windows), then guide it to the new location of the library.
    Windows users see tip at: https://discussions.apple.com/message/18879381

  • I would like to know how to extract my old contacts from the iTunes backup? Please explain in basic english i am a beginner

    I have had my old Iphone 5s replaced with a new one but I would like to know how to extract my old contacts from the iTunes backup? Please explain in basic english i am a beginner

    Hey,
    I think you will find that you have to have a debit/credit card stored on yur account regardless of whether your have iTunes Credit or want to purchase a free App. I don't know why, I assume its for ID verification or is part of the terms and conditions. I occasionally have to re-verify my credit card info even when just trying to run Update on one of my Apps or like I said downloading a free App.
    If you need further clarification all you can do is contact iTunes Support:
                   https://expresslane.apple.com/ServiceOptionAction.action
    Hope this helps. Andrew

  • Extracting a flat file from oracle table

    I have moved the knowledge module KIM ISO SQL to FileAppend from the Metadata to my project folder.
    But when I create an interface mapping the oracle table and a flat file on a different unix server, in the drop down menu , it shows only KIM SQL TO SQL and KIM Control Append.It does not show up the SQL to FileAppend knowledge module option.
    What should I do to extract a flat file from oracle table?
    Thanks
    Hima
    Overstock.com

    All IKM in the Drop Down Menu are dependent of the target technology.
    A question, at this interface, is your target table a file ?

  • In calendar program the time in outlook is one hour different from time in iphone appointments

    The time for all appointments in my outlook and synced to icloud are one hour different.  I was in Mexico which at the time was one hour different from pacific time.  How do I keep both times the same.

    You might want to go to icloud.com from your computer, sign into your iCloud account, click on your name, then confirm that you have the correct time zone set for iCloud, and that on your phone in Settings>General>Date & Time that you have Set Automatically turned On.

Maybe you are looking for