date format is lost (the "HH24:MI:SS" bit)

I would like to take a date value, a table and insert it into another array of the same type of data. Unfortunately I am not able to keep the HH24:MI:SS of the date when inserting.

Here is an example of what I'm doing: -.
-----------------------------------------------------
create table emp (id,name,valid_from)
    as
        select 1, 'david', to_date('18/11/2008 08:23:21', 'DD/MM/YYYY HH24:MI:SS') 
        from dual 
-----------------------------------------------------
 DECLARE

   TYPE t_cursor_usrr      IS REF CURSOR;
   v_cursor_usrr           t_cursor_usrr;
   
   l_emp                   emp%ROWTYPE;
   sql_stmt                VARCHAR2(32767);

 BEGIN
  
 OPEN v_cursor_usrr FOR 'SELECT * FROM emp';
    FETCH v_cursor_usrr INTO l_emp;
 
  sql_stmt:= 'INSERT INTO emp2(
   ID,         
   NAME,       
   VALID_FROM,
   ) VALUES ('    
    ||         l_emp.id                                          || ','        
    ||         l_emp.name                                        ||','       
    || '''' || to_date(l_emp.VALID_FROM,'DD/MM/YYYY HH24:MI:SS') || ')';
     
   dbms_output.put_line(sql_stmt);
  
 END;
It is the output: -.
INSERT INTO emp2(
   ID,         
   NAME,       
   VALID_FROM,
   ) VALUES (1,david,'18-NOV-08)
As you can see the date format has changed! Any ideas?

You are dynamic sql statements; Why you convert a date into a date? This is a BAD, BAD, BAD idea! You are forcing an implicit conversion to a string, and then back to a date, and it depends on what are your nls parameters. This is a bug that just waiting to happen!

Maybe you are after this instead:

sql_stmt:= 'INSERT INTO emp2(
   ID,
   NAME,
   VALID_FROM,
   ) VALUES ('
    ||         l_emp.id                                          || ','''
    ||         l_emp.name                                        ||''','
    ||' to_date('''||to_char(l_emp.VALID_FROM, 'DD/MM/YYYY HH24:MI:SS')||''',''DD/MM/YYYY HH24:MI:SS''))';

But why you do this instead of a straight line:

INSERT INTO emp2
SELECT ID, NAME, VALID_FROM
FROM emp

I don't understand!

Published by: Boneist on November 18, 2008 09:46

Tags: Database

Similar Questions

  • What is the date format used in the charts of Microsoft Support policy? Is the day/month/year or month/day/year?

    For example, the Date of beginning of life cycle shows 31/05/2001 (March 5) and the end of Support Date extended watch 07/12/2001 (12 July or December 7).

    The date format is month/date/year. This format is for the start date and end date for extended Support.
    In your example, the start date is May 31, 2001, and the end date would be July 12, 2001.

    I hope this helps.

    Marilyn

  • date format limits in the workflow

    Hello

    I try to add a time limit to one per programming workflows, but I have problem with the date format

    How do I format this date? ¿It is a date or a string?

    < workflowengine:completeassignment

    "site ="pub_id"

    "ID ="assignment_id"

    [ACTION ="action_comment" "]

    [comment ="comment" "]

    "NeXTSTEP ="next_workflow_step_id"

    "varname ="assignment_name"

    ["date limit ="deadline""]

    [assignmentlist ="participant_object" "] / >

    Thank you

    Finally, the date must be a string with the date in milliseconds.

  • Date format changes in the variable of presentation

    Hello
    I have a problem with the date stored in the variable of presentation.

    I have simple guest with the calendar control (default value date is set to session or deposit to the current date variable). Selected date is stored in the variable of presentation PP_DATE.
    I have a simple report with the title to view the contents of the variable PP_DATE.

    And now the problem.

    When I navigate to the page of dashboard with this report, I will get date of variable PP_DATE in a format (there are difference when I use the variable session or repository). After that I have will push the Start button, I get a different date format of variable PP_DATE.

    Screenshots are stored and described in this PDF file: [PDF with screenshots: https://docs.google.com/uc?export=download & id = 0B2LOPOBteIShMDRmYTJlYTItNmYyZC00ODdkLWE5NjktNzI1N2RlNWMwZjBk]

    There is difference between session variable and repository. When I use the reference variable I'll get "TIMESTAMP."... "the variable PP_DATE, which is the default initialization in variable Repository Manager. I tried to remove the boot by default, but I automatically added after saving changes.
    What is the default value of crimped guest of session variable, I get another date variable PP_DATE format that refers to DATE_TIME_DISPLAY_FORMAT = "yyyy-mm-dd hh:mi:ss.mss" (from NQSConfig.ini). I changed standard value DATE_TIME_DISPLAY_FORMAT ' yyyy/mm/dd hh' to "yyyy-mm-dd hh:mi:ss.mss" because I am reading data from excel, where dates are stored in the format MSSQL. But this isn't the reason for my problem. I have the same problem also with standard DATE_TIME_DISPLAY_FORMAT.

    The result of this strange behavior is that I get errors when I do some calculations (e.g. TimeStampDiff) to the variable PP_DATE. I get the error when I am accessing the dashboard page. Everything is ok after that I will push the Start button.

    You have some tips?

    Thank you

    Kishore Guggilla wrote:

    But I need sometimes current day default value in the command prompt, sometimes first day of the month etc...

    How do you manage that using variables to repository then?

    I have a block of initialization to initialize a few variables to repository.
    Initialization block a 1 day refresh interval.

    Select trunc (sysdate, 'mm'),
    LAST_DAY (trunc (sysdate, 'MM')),
    trunc (sysdate, 'DD'),
    trunc (sysdate, 'YYYY'),
    TO_DATE (' 31,12' | to_char (sysdate, 'YYYY')),
    TO_NUMBER (to_char (sysdate, 'YYYY')),
    TO_NUMBER (to_char (sysdate, 'MM')),
    TO_NUMBER (to_char (sysdate, 'DD')),
    trunc (ADD_MONTHS (sysdate-1), 'MM'),
    trunc (LAST_DAY (ADD_MONTHS (sysdate-1))),
    trunc (ADD_MONTHS (sysdate-2), 'MM'),
    trunc (LAST_DAY (ADD_MONTHS (sysdate-2))),
    trunc (ADD_MONTHS (sysdate,-3), 'MM'),
    trunc (LAST_DAY (ADD_MONTHS (sysdate,-3)))
    of the double

  • Lotus Notes Date format question on the XP machine

    User on the AD domain is part of the XP machine and the date in the Lotus Notes database format becomes jj/mm/aa in a field, but saves as 7 December 2012 without worrying for the user.

    I sign on the pc and everything works fine, any ideas?

    Hello Skeetersmom,

    The Microsoft Answers community focuses on issues and problems related to the consumer environment. Please join the public IT pro TechNet forums below:
    TechNet - Windows Server
     
    Thank you

  • How canI change the date format of dd/mm/yyyy to dd/mm/yyyy in filed?

    I just got and try things my new Alcatel fire E with FirefoxOS (just updated) 2.0.0.0.

    It is usual in most operating systems to be able to customize the date and time (among others). After a few hours of unsuccessful fiddling with the phone and checking the various forums, I came to the conclusion that it is currently not possible on my phone with this version of FirefoxOS. Or did I just miss something?

    Achim

    Hi achim_59,

    I understand that you want to set the date format to display the jj/mm/aaaa on your Firefox OS device.

    This feature has been implemented in Firefox OS v2.1. Unfortunately, this feature is not available in v2.0:

    For other questions about the updates and implementation of your specific device features, please contact your device manufacturer, Alcatel.

    -Ralph

  • How can I change the date format in Thunderbird for the list of received messages?

    Through 19/02/2015 12:28, I received my email with this format. Since that time, all the date Watch column is the time, the date does not show. How to get back to the default time and date format?

    The default is to show all the time on messages from today, with the date and time on all the other messages.

    http://KB.mozillazine.org/Date_display_format

  • Can not put date format as "yyyy-MM-dd" for Chinses (PRC) and English (United States) at the same time. Win 7 PRO

    Step 1. I choose Chinese (PRC) in the list format (region and language) and set the format of 'YYYY-MM-dd' date, apply. It is ok.

    Step 2. I choose English (United States) in the list format (region and language) and set the format of 'YYYY-MM-dd' date, apply. It is ok.

    Step 3. I chose the back to Chinese (PRC) in the format list (region and language), format date is reset to "YYYY/M/d", it is not ok for me.

    How can I set the format of a two language. ?

    Because I use the siemens industry software, when to change language it will read the date format different from the language that is displayed. My client want to see the same format.

    I tested under Win XP, it may set the format even in different languages

    Hi Jerry,

    Thanks for posting the request in Microsoft Community Forums.

    It is normal that you can not set the same date format for both languages at the same time. You will need to use the drop-down list to choose a date format customized if necessary.

    Hope this information helps.

  • XLS2COLLECTION in the collection date format

    Recently, I noticed the Date format imported into the collection as part of the XLS2COLLECTION is to come across as DD/MM/YYYY even if the XLS format is DD/MM/YYYY.  I can't seem to find a setting anywhere where it would change someone knows all the parameters that affect this format?

    XLS2COLLECTION

    I actually reached out to my contact at Oracle to get some clarification on this and he was kind enough to return after scanning through the code that is actually a HARD-CODED in the earphone date format.  He recommended to post something in the forum of listener to try and address the potential for improvement, but for now it looks like it's like that and in my case, I need to code exception to reformat the date in my application.

    Thanks for your comments to Mike!

  • In the RPD date format

    Hi gurus,
    The RPD, I have a condition where

    If (received_date-current_date) < X then...

    the date of receipt in the database is digital. Ex: 20040810

    How can I change the date format to match the default value for the current date in the expression builder.

    Thank you
    Avinash

    Looks like you use the calculations based on the fact table or could be physical columns.
    I suggest you use the logical columns so that you can use the column date (by received_date) your day sun.
    or else
    map the day Sunday to the fact table and to use physical expression for the same, the same as your other post with status = completed as I said in my last email.

    You must use the timestampdiff function.

    If brand aid

    Published by: Srini VIEREN on February 20, 2013 14:47

  • [OSB] Specification of date and hour format custom in the generator of MFL/Format

    It is possible to specify a date and time format customized by MFL (e.g. use of the Format, or directly from the MFL XML document generator). I work with a file format that contains dates of the form:
    Bq yyyymmmdd HHMM .
    that is a chain of fourteen characters, with a year to four numbers, three letters, two-digit day, a space as separator, followed by a two-digit hour and a two-digit minute. Each part is included in at least one of the available conversion specifiers, but date part, the part of time, or whole, are available in the form of a standard conversion specifier. I was not able to find a reference to formats date and hour customized using the Format generator or Non - XML data Mapping sample.

    Of course, the field can be treated as a string and converted downstream, but it had a native XML dateTime type as part of the conversion would be ideal.

    Note that the Native Format Manager supports date formats specified by the user, as shown in [http://download-uk.oracle.com/docs/cd/B31017_01/integrate.1013/b28994/nfb.htm#CCGJDGGJ].

    Thank you

    Geoff.

    Edited by: geofft 1 Sep 2008 11:09

    The asnwer is in your question:

    Note that the Native Format Manager supports date formats specified by the user, as shown in the http://download-uk.oracle.com/docs/cd/B31017_01/integrate.1013/b28994/nfb.htm#CCGJDGGJ.

    It is not possible.

    Marc

  • Can you help me to get the time format to match the XML dateTime?

    XML has a dateTime format that looks like this:

    2002-10 - 10T 12: 00:00 - 05:00

    and Im using the XMLElement() functions in some queries to produce an xml document however it truncates the portions of time stored data is just MM/DD/YYYY.

    I would use a to_char function but I don't know what date format in Oracle to use to match the portion of zone at the end (-05:00) and how to make so that it can accept as 't' in there as a separator, as defined in the XML schema specification:

    http://www.w3.org/TR/xmlschema-2/

    Anyone know?

    Hello

    Trant says:
    XML has a dateTime format that looks like this:

    2002-10 - 10T 12: 00:00 - 05:00

    and Im using the XMLElement() functions in some queries to produce an xml document however it truncates the portions of time stored data is just MM/DD/YYYY.

    I would use a to_char function but I don't know what date format in Oracle to use to match the portion of zone at the end (-05:00) and how to make so that it can accept as 't' in there as a separator, as defined in the XML schema specification:

    http://www.w3.org/TR/xmlschema-2/

    Anyone know?

    Try something like

    SELECT     TO_CHAR ( SYSTIMESTAMP
              , 'YYYY-MM-DD"T"HH24:MI:SSTZH:TZM'
              )
    FROM     dual;
    

    The sample output:

    2011-07-25T15:50:12-04:00
    

    TO_CHAR function is described in the SQL language reference manual:
    http://download.Oracle.com/docs/CD/B28359_01/server.111/b28286/sql_elements004.htm#sthref396
    Search for "Date Format models" in the index.

    Put the mat (that is, fixed) text, for example the letter 'T', in the output, include it in double - quotes.
    TZH is the hours and TZM time zone format specifier is synonymous of zone Minutes.

  • Reference Dell XT2: Lost the Zoom pinch when installed Windows 8 Pro

    I have a Dell Latitude XT2 I bought with Windows 8 Preview.  When I bought it, pinching at the zoom feature worked well.  Because not all the drivers/features were intalled correctly however, I did a clean install of Windows 7 (x 64) and reloaded everything.  I then bought Windows 8 Pro (x 64) and when I went to install, the installer asked me to remove the following as a mandatory step for installation:

    -Dell touchpad driver

    -Dell Data Protection Access (forcing in turn, deletion of Security Device Driver Pack & control Vault)

    -Intel 16.5.2.0 network connections

    -Duo N-Trig feel tactile multipoint package

    After Windows 8 is installed, the pinch in the zoom function no longer works.  I tried rolling back the drivers of the N-Trig, installation of the Suite of Vista x 64 and re-release to upgrade to Windows 8 pilots.  However, I can't retrieve the pinch in the zoom function.

    Either way, I am also unable to re - install the package access Data Protection and lost the fingerprint reader.  However, no pinch recovery aid to the zoom would be greatly appreciated.

    Thank you.

    Hello

    Thanks for the reply,

    I was talking to software programs that have been uninstalled during the upgrade to Windows 8.

    You can find these drivers under system utilities and you can also try updating the video drivers that is recommended and try to install in compatibility mode, in case of failure to help contact dell for the help these software are provided by the computer manufacturer, dell.

    You can contact Dell technical support at the following link:

    http://support.Dell.com/support/topics/global.aspx/support/DellCare/contact_technical_support?c=us&CS=19&l=en&s=DHS& ~ CK = mn

    Hope this information helps. If you have any other questions feel free to respond and we would be happy to help.

  • Date formats incompatible of apex between weekly and daily calendar

    I use the Apex ajax calendar to view activity.  My user has noticed that the date format changes between the weekly and daily life, that is to say the 07/08 (MM/JJ) and 08/07 (JJ/MM) respectively.  Is this a bug or is at - there somewhere some control of date format?

    I use the following to call pages

    Weekly

    JavaScript:apex.widget.Calendar.ajax_calendar ('W', 'same'); void (0);

    Every day

    JavaScript:apex.widget.Calendar.ajax_calendar (', 'same'); void (0);

    Thank you

    Drew

    Request Express 4.2.3.00.08

    Hello

    You can check your calendar template (shared components-> models-> calendar or go to the page that contains the schedule-> tree of shared components-> choose the calendar), if it uses the same date format for weekly view masks and every day? You will see variables substitution as #MM #, #DD # and so on.

    Concerning

    Patrick

    Member of the APEX development team

    My Blog: http://www.inside-oracle-apex.com

    APEX Plug-Ins: http://apex.oracle.com/plugins

    Twitter: http://www.twitter.com/patrickwolf

  • See date + hour in the date cells without changing the NLS settings

    We have a lot of columns date containing the date + time values, I often need to see while browsing the data in the table.

    Settings for the date format default NLS are exact to 'Russia', our database uses the default, which is then used by SQLDeveloper. For example, to display the values of time, I should write or select to_char manually with appropriate or the NLS under "Database" settings in preferences. Of course, it seems preferable to modify the NLS parameter.

    However, the date format change NLS has certain side effects. For example, it affects various tasks involving mainly exporters, which are launched from SQLDeveloper, because the to_char default to values date format also changes. Of course we could blame the lazy developers does not explicitly specify the formats, but it does not change the fact that the results of the task execution are 'bad', and which can be quite difficult to notice until the following tasks fail.  Also, if I'm not mistaken, NLS_DATE_FORMAT also affects to_date default format, making import text and date columns questioning pretty boring. It's better safe than sorry, so I need to keep the NLS parameters

    So, is it possible to set date format only for the display of the values in the data grid, without affecting the NLS settings somehow? I'm fine with just about anything, including writing an extension myself if necessary, I just need to work. If it is not possible, SQL Developer Team please add this parameter, or at least display a tooltip on mouseover, displaying the value of the cell "full"?

    NLS is the only way to affect the display of dates in the grids. To_char formatting is up to you good - he will use that you define in the function call.

Maybe you are looking for