SYSDATE format

Hi,
I have to insert SYSDATE in a table (field type - Date) in format 'yyyy-mm-dd hh12:mi:ss AM'.
I have tried "select to_date(sysdate, 'yyyy-mm-dd hh12:mi:ss AM') from dual " and the result was incorrect - 0008.01.09
whereas the result for "select sysdate from dual " was 2009.01.08 15:53:14
Then I have tried "select to_char(sysdate, 'yyyy-mm-dd hh12:mi:ss AM') from dual " and the result was correct - 2009-01-08 03:54:19 PM
but when i am doing the same in the insert statement, getting the following error -
ORA-01861: literal does not match format string
Please suggest some solution for this problem.
Thanks & Regards
PantherHawk

PantherHawk wrote:
Hi,
I have to insert SYSDATE in a table (field type - Date) in format 'yyyy-mm-dd hh12:mi:ss AM'.
I have tried "select to_date(sysdate, 'yyyy-mm-dd hh12:mi:ss AM') from dual " and the result was incorrect - 0008.01.09
whereas the result for "select sysdate from dual " was 2009.01.08 15:53:14
Then I have tried "select to_char(sysdate, 'yyyy-mm-dd hh12:mi:ss AM') from dual " and the result was correct - 2009-01-08 03:54:19 PM
but when i am doing the same in the insert statement, getting the following error -
ORA-01861: literal does not match format string
Please suggest some solution for this problem.
Thanks & Regards
PantherHawkJust insert sysdate as it's already of DATE datatype. You don't specify a format.
e.g.
insert into tableX (col1)
select sysdate from dual;

Similar Messages

  • Date format in 8i Lite ver. 4.0.0.2

    Hello,
    whenever I set the NLS_DATE_FORMAT to 'dd.mm.yyyy' I get the following error when selecting SYSDATE in SQL-Plus or opening a table containing dates in Navigator.
    Error:
    OCA-30023: error fetching result set
    [POL-2416] invalid date/time format
    Can anyone help with this ?
    thanks in advance
    Joachim Helf

    Hi,
    the sysdate format is set by the NLS_DATE_FORMAT on your machine.
    if the database is on your machine you can set the NLS_DATE_FORMAT by going to DOS prompt and typing set NLS_DATE_FORMAT <format> and then use sqlplus.
    sqlplus is a client utility - it behaves upon user enviroment.
    if you are using windows based operating system just use regedit and add
    HKEY_LOCAL_MACHINE/SOFTWARE/ORACLE/NLS_DATE_FORMAT (value:DD-MM-YYYY HH24:MI:SS)
    if the database is on a server and you are the client just remove NLS_DATE_FORMAT from user settings and connect to sqlplus.

  • Default value = sysdate

    Hi
    How can i set as default value the currant sysdate to a date picker item?
    Thank you

    HI,
    ========================================================
    There is a default value area in the item's definition. Make sure you set it to TO_CHAR(SYSDATE, '<format string>') using the same format as the data picker expects.
    ========================================================
    Yes i have tried the same,but it is not updated.
    Attribute Settings
    Dispaly As ---- Data picker
    Format --------- DD-MON-YYYY HH24:MI
    Default type -- Pl/SQL Expression
    Defalut Value-- to_char(sysdate,"DD-MON-YYYY HH24:MI")
    Kindly clarify.
    Best Regards
    Perumal Swamy.R

  • Sysdate on dbms_job Next_date

    Hi, actually i did post this before, i gonna repost again since no one reply me
    my current code is like this:
    DECLARE
    JOBNUMBER NUMBER;
    BEGIN
      dbms_job.submit(JOB => jobnumber,
      WHAT => 'BEGIN .........end;',
      NEXT_DATE => to_date('26/06/2009 23:00','DD/MM/YYYY HH24:MI'),
      INTERVAL => '(SYSDATE) + 1' );
    COMMIT;
    END;how to make it run on today date (sysdate) with the run time set on 11pm. The all_jobs should be like this:
    Job     LAST_DATE       LAST_SEC    THIS_DATE  THIS_SEC   NEXT_DATE     NEXT_SEC        TOTAL_TIME                                      TOTAL INTERVAL
    525     26-JUN-09     23:00:00     (null)     (null)     27-JUN-09     23:00:35     21.00000000000000000000000000000000000004     (sysdate) + 1Thanks
    Edited by: newBJeat on Jun 26, 2009 12:40 AM
    Edited by: newBJeat on Jun 26, 2009 12:48 AM

    Hi
    Current code works fine, but didn't work as what i want. Yeah in my case both are null, like this:
    Job  LAST_DATE LAST_SEC THIS_DATE THIS_SEC  NEXT_DATE  NEXT_SEC   TOTAL_TIME    TOTAL INTERVAL
    530     (null)     (null)     (null)     (null)     26-06-2009 23:00:00     23:00:00     (SYSDATE) + 1I just need the job run everyday exactly on 11pm follow the system date and keep run routine without user to run manually....I just don't know how the sysdate format is? (like what in my code
    NEXT_DATE => to_date('26/06/2009 23:00','DD/MM/YYYY HH24:MI'),where sysdate have to place in my code???
    Thanks
    Edited by: newBJeat on Jun 26, 2009 1:02 AM
    Edited by: newBJeat on Jun 26, 2009 1:06 AM

  • How to subract char with number

    Hi Experts
    Here is my requirement
    select sysdate-1 from dual -- Goes to previous date sysdate formate is DD-MON-RRRR
    Iam changing this format as MM-DD-RRRR
    select to_char(sysdate, 'MM-DD-RRRR') From Dual -- Here now how can I go to my previous date with this?
    I am trying this
    select to_char(sysdate, 'MM-DD-RRRR') ,-1 From Dual -- here I am subtracting Char with no which is not possible how can i achieve this ?
    Regards
    Suresh Babu

    subtract then convert:
    select to_char(sysdate-1,'mm-dd-yyyy')
    from dual;
    TO_CHAR(SY
    05-23-2013?
    nb 'rr' only makes sense for 2-digit years.

  • Datetime validation

    In the form I have a column as time of irradiation which is in the format HH24:MI . Data type in the form is datetime.
    I have to have a validation to see if this field is equal to system time or less. If not equal or greate than system time, then I have to give a message.
    on form up this field is populated by
    :plt_irradiation.time_of_irradiation := sysdate; (format mask in the form is HH24:MI). Displays the right time.
    But when I do validation to check using this code, it does not work
    . What is the right one to use?
    declare
    *     v_date varchar2(11);     *
    Begin     
    *     select to_char(sysdate,'HH24:MI') into v_date from dual     ;               *
    *     If :plt_irradiation.time_of_irradiation = v_date or :plt_irradiation.time_of_irradiation < v_date then*
    *     null;*
    else
    msgbox.show('Time Error', 'Irradiation Time should be system time or less than system time, please verify and re-                                       enter.', 'error');
    *     raise form_trigger_failure;*
    End if;
    End;
    Thanks in advance
    Anu

    It should work. Check the content of your date-field by putting a
    message(TO_CHAR(:plt_irradiation.time_of_irradiation, 'DD.MM.YYYY HH24:MI:SS') || '#' || TO_CHAR(SYSDATE, 'DD.MM.YYYY HH24:MI:SS'));SYNCHRONIZE;PAUSE;before your IF

  • URGENT - RMAN restore help needed

    Hi,
    I have inherited an Oracle 9i system ( 9.2.x ) that needs to have a RMAN based backup from it restored onto a different oracle server of the same version.
    Thanks so much for your assistance on this.
    I also forgot to mention we run Oracle on a windows 2003 server.
    Well we have asubdirectory called Rman, so i figured thats whats doing the work.
    The output from the backup is :
    - In the exp directory :
    one .dmp file
    - In the Rman directory, 4 files per nightly backup, which have the format of :
    <dbname>_<date>S<4 digit numer that increments each backup>P1
    <dbname>_<date>S<4 digit numer that increments each backup>P2
    <dbname>_<date>S<4 digit numer that increments each backup>P1
    <dbname>_<date>S<4 digit numer that increments each backup>P1
    On another drive I have found :
    - seven .DBF files
    - one .CTL file
    One another drive I found :
    - one .ARC file
    - one .CTL file
    - REDO01.LOG,REDO02.LOG,REDO03.LOG files
    I also found the script that runs :
    rman target / catalog xxusernamexx/xxpasswordxx@PRD_DBA01 @D:\DBA\dbaadm\scr\RmanFull.rcv >> %logfile%
    Where Rmanfull.rvc is as shown below :
    DELETE NOPROMPT FORCE BACKUPSET COMPLETED BEFORE 'sysdate-8' DEVICE TYPE disk;
    DELETE NOPROMPT FORCE ARCHIVELOG ALL COMPLETED BEFORE 'sysdate-8' BACKED UP 2 TIMES TO DEVICE TYPE disk;
    BACKUP INCREMENTAL LEVEL 0 VALIDATE database PLUS archivelog;
    BACKUP INCREMENTAL LEVEL 0 TAG 'XXXXXXXX-Current' database PLUS archivelog NOT BACKED UP 2 TIMES;
    BACKUP DEVICE TYPE disk TAG 'XXXXXXX-BkupSet' BACKUPSET COMPLETED BETWEEN "TO_DATE(TRUNC(sysdate-1))" AND "TO_DATE(TRUNC(sysdate))" FORMAT 'D:\ORABackup\%d\Rman\%d_%T_s%s_p%p' DELETE INPUT;
    RESTORE VALIDATE database;
    RESTORE VALIDATE controlfile TO 'D:\ORABackup\Null\control.ctl';
    RESTORE VALIDATE spfile TO 'D:\ORABackup\Null\spfile.ctl';
    I have put in XXXXXXXX to blank out some names.
    I will do some reading, however what are your thoughts as to what this means for how I would do a restore of this database please? Not being lazy here, as I understand it oracle databases can get complex in configuration etc which is why i decided to ask people who do this all the time for a bit of guidance.
    Thanks in advance,
    Cheers
    SG
    Edited by: user11915486 on 17/09/2009 22:37

    user11915486 wrote:
    Hi,
    I have inherited an Oracle 9i system ( 9.2.x ) that needs to have a RMAN based backup from it restored onto a different oracle server of the same version.
    Thanks so much for your assistance on this.
    I also forgot to mention we run Oracle on a windows 2003 server.
    Well we have asubdirectory called Rman, so i figured thats whats doing the work.
    The output from the backup is :
    - In the exp directory :
    one .dmp file
    - In the Rman directory, 4 files per nightly backup, which have the format of :
    <dbname>_<date>S<4 digit numer that increments each backup>P1
    <dbname>_<date>S<4 digit numer that increments each backup>P2
    <dbname>_<date>S<4 digit numer that increments each backup>P1
    <dbname>_<date>S<4 digit numer that increments each backup>P1
    On another drive I have found :
    - seven .DBF files
    - one .CTL file
    One another drive I found :
    - one .ARC file
    - one .CTL file
    - REDO01.LOG,REDO02.LOG,REDO03.LOG files
    I also found the script that runs :
    rman target / catalog xxusernamexx/xxpasswordxx@PRD_DBA01 @D:\DBA\dbaadm\scr\RmanFull.rcv >> %logfile%
    Where Rmanfull.rvc is as shown below :
    DELETE NOPROMPT FORCE BACKUPSET COMPLETED BEFORE 'sysdate-8' DEVICE TYPE disk;
    DELETE NOPROMPT FORCE ARCHIVELOG ALL COMPLETED BEFORE 'sysdate-8' BACKED UP 2 TIMES TO DEVICE TYPE disk;
    BACKUP INCREMENTAL LEVEL 0 VALIDATE database PLUS archivelog;
    BACKUP INCREMENTAL LEVEL 0 TAG 'XXXXXXXX-Current' database PLUS archivelog NOT BACKED UP 2 TIMES;
    BACKUP DEVICE TYPE disk TAG 'XXXXXXX-BkupSet' BACKUPSET COMPLETED BETWEEN "TO_DATE(TRUNC(sysdate-1))" AND "TO_DATE(TRUNC(sysdate))" FORMAT 'D:\ORABackup\%d\Rman\%d_%T_s%s_p%p' DELETE INPUT;
    RESTORE VALIDATE database;
    RESTORE VALIDATE controlfile TO 'D:\ORABackup\Null\control.ctl';
    RESTORE VALIDATE spfile TO 'D:\ORABackup\Null\spfile.ctl';
    I have put in XXXXXXXX to blank out some names.
    I will do some reading, however what are your thoughts as to what this means for how I would do a restore of this database please? Not being lazy here, as I understand it oracle databases can get complex in configuration etc which is why i decided to ask people who do this all the time for a bit of guidance.
    Thanks in advance,
    Cheers
    SG
    Edited by: user11915486 on 17/09/2009 22:37Hi and welcome to Forum!
    I'd suggest you firstly to refer to [Administrators Guide documentation |http://download.oracle.com/docs/cd/B19306_01/server.102/b14231/toc.htm] - to have basic knowledge of Oracle database and file types. Without having this knowledge, you will not be a successful DBA
    Let's analyze the script:
    DELETE NOPROMPT FORCE BACKUPSET COMPLETED BEFORE 'sysdate-8' DEVICE TYPE disk;
    It deletes backupsets which completed before 8 days before (From disk, not from tape)
    DELETE NOPROMPT FORCE ARCHIVELOG ALL COMPLETED BEFORE 'sysdate-8' BACKED UP 2 TIMES TO DEVICE TYPE disk;
    Deletes all archived redo log files which were backed up two times and completed before 8 days
    BACKUP INCREMENTAL LEVEL 0 VALIDATE database PLUS archivelog;
    Validates (not backups- just checks whether this script will run successfully ) the backup of database with all archived redo log files
    BACKUP INCREMENTAL LEVEL 0 TAG 'XXXXXXXX-Current' database PLUS archivelog NOT BACKED UP 2 TIMES;
    Backups Incremental level 0 backup of all database (which backups all the database with incremental option which will be used in the future when you'll take incremental 1 backups) and archived redo log files which not backed up 2 times and give it special Tag name to use it in the future just providing only tag name
    BACKUP DEVICE TYPE disk TAG 'XXXXXXX-BkupSet' BACKUPSET COMPLETED BETWEEN "TO_DATE(TRUNC(sysdate-1))" AND "TO_DATE(TRUNC(sysdate))" FORMAT 'D:\ORABackup\%d\Rman\%d_%T_s%s_p%p' DELETE INPUT;
    Backups all backupsets wich completed in 1 day (between yesterday and today) and gives it specific name and deletes original backupsets
    RESTORE VALIDATE database;
    Checks restoration of database (whether it is successful or not)
    RESTORE VALIDATE controlfile TO 'D:\ORABackup\Null\control.ctl';
    Checks restoration of controlfile
    RESTORE VALIDATE spfile TO 'D:\ORABackup\Null\spfile.ctl';
    Check restoration of spfile As a conclusion, I'd suggest you to refer to [Oracle Database Backup and Recovery Basics - 10g Release 2 (10.2)|http://download.oracle.com/docs/cd/B19306_01/backup.102/b14192/toc.htm] documentation to understand basics of RMAN Backup and Recovery
    Kamran Agayev A. (10g OCP)
    http://kamranagayev.wordpress.com
    [Step by Step install Oracle on Linux and Automate the installation using Shell Script |http://kamranagayev.wordpress.com/2009/05/01/step-by-step-installing-oracle-database-10g-release-2-on-linux-centos-and-automate-the-installation-using-linux-shell-script/]

  • Simple Date Problem

    Hello,
    I'm stuck against a simple date query and need some help. Can anyone please shed some light on this?
    Our Environment is: oracle 8i and SYsdate format is: GMT.
    I have a table say employee with the following fields;
    Employee_id,employee_name,hire_date,is_new
    I have to find:
    Select employee_name
    From employee
    Where is_new = ‘Y’
    And hire_date between (00 GMT) and now.
    So, my problem is:
    How do I do the AND Clause?
    How can I get between 00GMT of today and now.
    Any help will greatly be appreciated. THanks in advance
    simak

    You could also use
    Select employee_name
    From employee
    Where is_new = ‘Y’
    And hire_date >= trunc(sysdate);

  • How to transform DATE?

    Hello!
    Now I do "select SYSDATE from dual" and receive "24-MAY-01".
    How I can receive date and time in other format by default without "TO_CHAR(SYSDATE,Format)"?

    change u're default date format by
    ALTER SESSION SET NLS_DATE_FORMAT='format_string';

  • Invalid format of sysdate in variable

    Hi all,
    Now i am using "select sysdate from dual" and when i am checking the value in history its giving something like 12-04-2011 AM 10:30:01.0
    I dont understand why that .0 (point zero is coming).When i am using sysdate in interface its giving the perfect one.
    Please suggest.
    Thank You.
    DG

    Hello DG
    You can use SELECT TO_CHAR(SYSDATE, 'DD-MM-RRRR') FROM DUAL
    In your interface, map the variable to the column, using to_date(#VARIABLE, 'DD-MM-RRRR') - this is dependent on the format you require.Hope its going to help you.
    Thanks

  • Select sysdate from dual (to custom format).

    Dear all,
    i like to SELECT SYSDATE FROM DUAL, and run this result in a query something like:
    SELECT X, Y, Z FROM TABLENAME WHERE ACCESSDATE = (SELECT SYSDATE FROM DUAL);
    The problem is that the value of ACCESSDATE is in an format like DD-MM-YYYY and that sysdate form dual is
    DD-MON-YYYY.
    How do i get sysdate into the format DD-MM-YYYY?
    Thanks already,
    Johan.

    Perhaps usefull for performance:
    first of all: no subselect is not needed. sysdate can be used as an argument directly (all functions are).
    secondly, if accessdate is of type 'date' and the table has a lot of rows, converting it to a char will bypass the index usage. Instead, if you are worrying about the time try this (the display format is of no concern here if the datatype is date):
    SELECT X, Y, Z FROM TABLENAME WHERE ACCESSDATE >trunc(sysdate) and ACCESSDATE < trunc(sysdate+1);
    if accessdate is of type 'varchar2' then this should be enough (and should remain using the indexes on accessdate):
    SELECT X, Y, Z FROM TABLENAME WHERE ACCESSDATE = to_date(sysdate,DD-MM-YYYY);
    Hope this helps,
    L.

  • How To Format Sysdate

    How do you format sysdate? I want the results to be in date format, but I only want the date itself without the time added as
    6/14/2010
    The To_Date function doesn't seem to work as it converts a string to a date and sysdate isn't a string?
    Thanks for any help..

    user12296489 wrote:
    Turns out that I can specify to change the format from text to date when I import the data into access. So, after using To_Char to save the data in mm/dd/yy text format, I can import that, changing it to date format upon the import..That sounds like the correct thing to do.
    You have to remember, when you talk about "format", you are talking about how something is displayed or output and that means you are talking about strings. Only character based datatypes are strings (VARCHAR2, CLOB) and the other datatypes are internal representations that have to be formatted to strings to be displayed.
    For examples, if I look at the string 'FRED'...
    SQL> select 'FRED', dump('FRED') as dmp from dual;
    'FRE DMP
    FRED Typ=96 Len=4: 70,82,69,68You can see that it's stored internally as 4 bytes each of which are the ascii values of the 4 characters in the string. There's no formatting needed as it's already a direct representation of the ASCII characters needed to display it.
    However, if I look at sysdate...
    SQL> select sysdate, dump(sysdate) as dmp from dual;
    SYSDATE             DMP
    15/06/2010 08:28:04 Typ=13 Len=8: 218,7,6,15,8,28,4,0Whilst it displayes in DD/MM/YYYY HH24:MI:SS format, the internal storage of it is something completely different. It's made up of 8 bytes of data that sort of (but not fully) represent the number parts of the date, but contain non of the formatting that would display it as it appeared to me.
    The format for the date comes from my local session settings, which tell it how to format it as a string. I can change this...
    SQL> alter session set nls_date_format='DD-MON-YYYY';
    Session altered.
    SQL> select sysdate, dump(sysdate) as dmp from dual;
    SYSDATE     DMP
    15-JUN-2010 Typ=13 Len=8: 218,7,6,15,8,32,44,0Now the date is displayed differently, but internally it's still represented by 8 bytes, that hasn't changed.
    So, if you want to format dates, or numbers, you need to use the TO_CHAR function and specify the format it should be displayed in. You can use the NLS settings, but they are session specific and you would need to be careful using them. It's always better to be explicit about the format you want using TO_CHAR instead.

  • How to insert sysdate in 24hr format using select

    hi,
    I m just modifying my previous question
    what if I have to insert the date using
    insert into abc select sysdate from dual;
    where abc is having one column sdate of type date.
    this date inserted through the query to be inserted in 24hr
    format.

    a date is just a number, it doesn't have a format. so your
    insert string will work. to see the time element in 24 hour
    clock all you have to do is
    select to_char (col1, 'DD-MON-YYYY HH24:MI:SS') from abc;
    easy.
    APC

  • Formating sysdate function output

    Hi Gurus,
    I'm doing a POC with BPEL and XMLPublisher and need the current date in a rtf template. I found the function <?xdofx:sysdate()?>, this output is not in the correct format and I need to reformat the sysdate output.
    I also found the information about date formatting, but all this information refer to the field name. How could I reformat the sysdate function output?
    Thanks in advance.

    Hi mcarlosro,
    I hope you will be using form field method to place the sysdate....
    Do one thing ...in form field choose the type as a date...or choose current date.... if you r choosing current date.. hen no need to give any code... but i will suggest you to go with this code whatever you are having for this field........ and choose type as a date and type format.. whatever you want...... you can type it there....
    I hope it will help you.....
    Regards
    Ravi

  • Sysdate - how to convert into a certain format

    Hi,
    I am trying to use sysdate as a default parameter in one of my reports and getting an error message (ORA-01843: not a valid month)...
    my sysdate is coming up in the following format (DD-MMM-YY) and is giving an error message... but when I tried the date manually in following format (MM/DD/YYYY) it worked...
    may I know how to convert sysdate into the following format MM/DD/YYYY
    thanks in advance

    my sysdate is coming up in the following format (DD-MMM-YY)
    There is no "MMM" format model. And how often does it have to be explained that 2-digit year formats are just wrong?
    Suggest you post the query or expression that is causing the error. Generally there is no reason to convert <tt>sysdate</tt> away from a <tt>DATE</tt> type for anything other than display purposes. It is more likely that the error is due to an implicit conversion of another value to <tt>DATE</tt> using a non-default or incorrect format mask.
    Also post the result of running
    select * from v$nls_parametersin the SQL Workshop.
    Edited by: fac586 on 13-Jun-2011 18:00

Maybe you are looking for

  • HAL, and daemons in general

    Hi. I'm new to the forums, and this is the third thread I've started; I haven't been getting any responses, so I hope I'm not posting in the wrong place, spamming, or being otherwise annoying. When I boot up, I get a message about my hardware abstrac

  • Laptop crashed, want to re-install on new computer

    Hi there, I had a laptop from new about 4 years ago with Photoshop elements 7 installed. It crashed so I bought the Adobe Photoshop Elements 10 and Premiere Elements 10 bundle and since the laptop crashed again. Now I have this new laptop (as of last

  • Linking UDF to User Defined Table

    Dear Experts,   I have a UDF on the batch tables that I would like to link to a User defined table. After creating the link, the UDF drop down cannot open up to display anything. The drop down box is there on the UDF but cannot open or drop to displa

  • 2 products installed in this Oracle Home

    Our security scanner is indicating that our Oracle 10g install has a vulnerability that should have been address with the install of CPUApr2011.  Our server is patched with every 10g CPU until end of life in Aug 2013, so I know it is a false failure.

  • /Users Access denied

    Hi all I have been trying to do some work in the catalog manager. I login as Administrator in online mode ... I can get to the shared folder, system folder. When I go to users I can access /users/Administrator However, I cannot seem to access the oth