How to truncate sysdate

Hello friends

I created a table called newspaper as follows

create table log (number, login_date date logid);
Insert in the journal values(101,sysdate);

After 10 minutes, I created a slider as follows...

declare
uname varchar2 (30);
logdate date;
cursor name_c is
Select logid, login_date in the newspaper where logid = 101 and login_date = sysdate;
Start
Open name_c;
extract name_c in uname, logdate;
if(name_c%found) then
dbms_output.put_line ('FOUND');
end if;
close name_c;
end;
/

Set serveroutput on;
PL/SQL procedure successfully completed.



But I did get no results... I found the reason that when I insert in the sysdate table stores all fields
including hour, min, sec, etc... But I extract sysdate cursor [after 10 min] right now the fields change. Then only the cursor don't fetch no line... Please, help me to extraction of the row in the table of the newspaper...
How to truncate field sysdate to extract only date like('18-feb-2011')...

Change the cursor like query

cursor name_c is
select logid,login_date from log where logid=101 and trunc(login_date)=trunc(sysdate);

Edited by: Oracler February 17, 2011 22:48

Edited by: Oracler February 17, 2011 22:48

Tags: Database

Similar Questions

  • How to convert sysdate to any given time zone

    Hello friends,

    I have asked this question in an interview and I couldn't respond.

    Question:


    How to convert sysdate to any given time zone

    as sysdate IST or EDT etc.

    Sriram_91 wrote:

    Hello friends,

    I have asked this question in an interview and I couldn't respond.

    Question:

    How to convert sysdate to any given time zone

    as sysdate IST or EDT etc.

    Don't know if you want, but here goes:

    My current timzone, I am in the time zone of Phoenix, AZ is (including 7 hours BEHIND GMT aka - 07:00).  Therefore, the MST.  To convert it to EDT (aka New York City), I do this:

    SELECT SYSTIMESTAMP AS Phoenix_TZ
          ,CAST(SYSTIMESTAMP AT TIME ZONE 'America/New_York' AS TIMESTAMP WITH TIME ZONE) AS NY_TZ
      FROM dual;
    

    @

    I hope this helps.

  • How to truncate posts in the blog list?

    How to truncate posts in the blog list? We tried to enter {tag_blogpostbody, characters, read-more-link} OR {tag_blogpostbodypreview, text} in the html file. But it comes from words across the page.

    Access to, the Site Manager > Module models > Blog Layouts > layout list Blog Post

    Find out more about the HELP , then follow the instructions.

  • How to display SYSDATE within an HTML region?

    In my view, it should be a trivial problem, but I tried for awhile without result. My question is how to display the current date in an HTML area. I want to use it as a welcome message.
    Hello, &APP_USER.! Today is [how to substitute SYSDATE here?]

    You can define a page element by default for formatting SYSDATE, then refer to this article in the HTML area.

  • How to truncate the output of the field in the column "LONG".

    Hi all

    I have been asked to retrieve all records from a table with a column that has been initially formatted with the format "LONG".

    How can I truncate the output of this area without having to show the Junk characters?

    Very appreciated

    JR

    Wrong forum!

    This forum is ONLY for questions/problems on Sql Developer and your question has NOTHING to do with this product.

    Please mark the thread ANSWERED and repost it in the SQL/PL/SQL forum.

    SQL and PL/SQL

    When you repost you must SHOW an example of what you are wanting to do. You should also explain what you mean by 'LONG Format' - I have never heard such a thing.

  • How to truncate text in Jdeveloper Studio Edition version 11.1.1.7.0 af:commandLink

    Hello

    I want to truncate text in commandLink. How can I do this?

    Are there similar functionality, as in truncateAt of outputText.

    Thank you

    Vicky

    Hello

    N ° CommandLink does not property of truncateAt.

    However, you can surround an outputText with commandLink to reach your usecase.

    Ex:

    Arun-

  • How to truncate the query

    Hello

    with this sql:

    SELECT c.country_name, l.city
    FROM countries c, locations l
    

    I have 575 lines,

    How can I truncate the output to 100 lines?

    Add this predicate:

    WHERE ROWNUM<=>

  • How to truncate a string to a particular character in sql

    Hi friends,
    I wanted to truncate the string up to the. (dot).
    as for ex Supplier.670.

    I want only the supplier to take how I can do
    How to do this

    Thank you
    SQL>
    SQL> SELECT REGEXP_SUBSTR( 'supplier.670', '[[:alpha:]]*')    FROM dual;
    
    REGEXP_SUBSTR('SUPPLIER.670','
    ------------------------------
    supplier
    SQL> SELECT REGEXP_SUBSTR( 'supplier.670.4576', '[[:alpha:]]*')    FROM dual;
    
    REGEXP_SUBSTR('SUPPLIER.670.45
    ------------------------------
    supplier
    SQL> SELECT REGEXP_SUBSTR( '[email protected]', '[[:alpha:]]*')    FROM dual;
    
    REGEXP_SUBSTR('[email protected]
    ------------------------------
    supplier
    SQL> SELECT REGEXP_SUBSTR( 'supplier 670.4576', '[[:alpha:]]*')    FROM dual;
    
    REGEXP_SUBSTR('SUPPLIER670.457
    ------------------------------
    supplier
    
    SQL> 
    
  • How to set sysdate as date in dashboard prompt by default

    Hi all

    I want to set default date (sysdate) in guest of dashboard. How to do this.
    I've not done this before.
    tell me clearly.

    Thanks in advance.

    Hi Anand,

    Try this:
    (1) will put in default of-> Variable.
    (2) @{system.currentTime}

    Good luck and if you have found this helpful, please give points!

    Best regards

    -Joe

  • How to truncate oracle.jbo.domain.date

    Hello
    I have problem to convert oracle.jbo.domain.date. Now, I got the current date of pagecontext, but this is the format yyyy-mm-dd hh. I want only aaaa-mm-jj, so I want to truncate the time of oracle.jbo.domain.date. And I want to got to this Date no chain. I found Date.truncate () there, but I don't know how to use it.
    Could someone help to give me an example?

    Best regards
    Eileen

    Hello

    use,

    currentDate = am.getOADBTransaction () .getCurrentUserDate () oracle.jbo.domain.Date;
    Date testdate = (Date) currentDate.dateValue ();

    Thank you
    Gerard

  • How to display sysdate + 1 on the MessageTextInput field with the data type Date

    Hello

    I have a class messageTextInput that the data type Date. I am able to view the sysdate in the area of the messageTextInput, now my requirement is I have to post sysdate + 1. Please let me know how to proceed.

    This is my code:

    TXN OADBTransaction = (OADBTransaction) am.getTransaction ();
    EntryDate date = txn.getCurrentDBDate ();
    System.out.println ("DATEEE > > > > > > > > >" + entryDate);
    masterRow.setAttribute ("EffectiveDate", entryDate);

    Kind regards
    Suresh.

    SELECT double ADD_MONTHS(sysdate,12)

  • How to truncate a timestamp data type

    I can't count the number of requests that I have written over the years where the trunc (date) was a very useful function. However, I can't find a way to accomplish the same thing when dealing with a timestamp data type. According to the 10 g reference SQL, function 'tronque()' is supposed to take care of timestamp types. However, my 10.2.0.4 database always converts the result to type date.

    Here's what I'm trying to basically do:

    SQL > select count (*)
    sys.aud $2
    3 where ntimestamp # > sys_extract_utc (trunc (systimestamp))
    6 m
    where ntimestamp # > sys_extract_utc (trunc (systimestamp))
    *
    ERROR at line 3:
    ORA-30175: invalid type for an argument

    I was able to find a way to get a truncated time stamp:

    SQL > select cast (trunc (sysdate) timestamp with local time zone)
    2 double
    3.

    CAST (TRUNC(SYSDATE,'DAY') ASTIMESTAMPWITHLOCALTIMEZONE)
    ---------------------------------------------------------------------------
    JULY 27 09 12.00.00.000000 AM

    However, this is a powerful approach ugly. Am I missing something? Any help is appreciated!

    Stan

    Hello

    You can do it.

    SQL> select
      2  cast(
      3          trunc(sysdate)
      4          as timestamp)
      5  from dual
      6  /
    
    CAST(TRUNC(SYSDATE)ASTIMESTAMP)
    -----------------------------------------
    27-JUL-09 12.00.00.000000 AM
    

    HTH
    SS

  • How to truncate timestamp?

    Hi all

    I want to see only the HH24:MI:SS time. In other words, I don't want to see + 00 05:00:00.000000 I want to see 05:00

    version: 11g

    Select sysdate from dual;

    11/04/2015 11:05:41

    Select to_timestamp (to_char (sysdate, 'HH24:MI:SS'), 'HH24:MI:SS') - to_timestamp (to_char ((sysdate-(1/24)), 'HH24:MI:SS'), 'HH24:MI:SS') of double

    Thank you

    SQL> with t
      2  as
      3  (
      4  select (sysdate - (sysdate-(1/24))) day to second diff
      5    from dual
      6  )
      7  select to_char(extract(hour   from diff), 'fm09') || ':' ||
      8         to_char(extract(minute from diff), 'fm09') || ':' ||
      9         to_char(extract(second from diff), 'fm09') diff
     10    from t;
    
    DIFF
    -----------
    01:00:00
    
  • How to truncate 1000 rows from a table of 7000 lines?

    Hello

    Please give me a quick answer to truncate the 1000 rows from a table of 7000 lines... I don't want to truncate the entire table

    Thank you all for the valuable support,

    My activity is still ongoing... Somehow my client was not specific about what lines are deleted. It has no date column in the table to delete records by date...

    The table contains information about the error logs, so he wanted to keep a few lines and remove the rest... and then copy the table to another database.

    So right now using this query:

    SQL > delete (select * from ) where rownum<>;

    Once again thank you to all...

  • How to truncate the table in a pl/sql block

    Hello guys, I'm trying to truncate a table that includes data using a pl/sql block, so if the table has even a single row then the truncate should run. to do this, I wrote the following code


    declare
    number num.
    Start
    Select count (*) in the num from table_name;
    If num > 0 then
    truncate table table_name;
    end if;
    end;

    Now, when I execute the pl/sql block, I get the following error.

    PLS-00103: encountered the symbol "TABLE" when the expected in the following way:

    When I run the truncate without pl/sql command, it runs very well.

    Can someone please where I'm wrong.

    Thank you

    Published by: 969224 on April 23, 2013 08:08

    969224 wrote:
    Hello guys, I'm trying to truncate a table that includes data using a pl/sql block, so if the table has even a single row then the truncate should run. to do this, I wrote the following code

    declare
    number num.
    Start
    Select count (*) in the num from table_name;
    If num > 0 then
    truncate table table_name;
    end if;
    end;

    Now, when I execute the pl/sql block, I get the following error.

    PLS-00103: encountered the symbol "TABLE" when the expected in the following way:

    When I run the truncate without pl/sql command, it runs very well.

    Can someone please where I'm wrong.

    Thank you

    Published by: 969224 on April 23, 2013 08:08

    DDL is not allowed directly within PL/SQL procedures.

    You must (ab) use EXECUTE IMMEDIATE issuing the DDL

Maybe you are looking for

  • reset pulse

    I use the API C/C++ OR-DAQmx. How can I set up a counter to produce a single pulse redeclenchables? In other words, I need a pulse output, and then the pulse is generated, if a new trigger comes in, it gives the meter so that the timing of the pulse

  • write a string 2d for the excel file

    When I try to put my table in excel, the message appears and I can't open the file. The path is correct.

  • Installation of Vista updates: unknown error, code: 80200024

    Try to install 9 'important' updates, receive an error message, "Windows Update has encountered an unknown error." Error code is 80200024. Edit: Sorry, I clicked on 'Vista' as the version of windows, but it displayed in the Windows 7 forums.  Apologi

  • Vista Service Pack 2 will not install on my Vista.

    Since the Service Pack was released I tried to install it. And each time, repeatedly, he'll prepare my computer, tell me to restart, it will do the "install Windows Vista Service Pack 2 1/3 0% Complete" thing when I restart and right at the end where

  • Phone call claiming to be from Microsoft

    I also received a phone call from the India that claims to be from Microsoft.  They said that my computer had a bad virus.  I gave them remote access to my computer.  Also the last 6 digits of my registration code.  Now, I think I messed up royally.