Inserting Date and Time Issues

Hi All,
I have a very simple select query as follows... UPLOAD_DATE is held in table1 in the following format:     23/01/2012 13:04:36
<cfquery name="test" datasource="test">
SELECT  UPLOAD_DATE
FROM     TABLE1
</cfquery>
and I loop around the above query to insert into another table...
<cfloop query="test">
     <cfquery name="make_tfer2" datasource="test">
          INSERT INTO TABLE2
               (UPLOAD_DATE)
          VALUES
               (#test.UPLOAD_DATE#)
     </cfloop>
</cfloop>
But, when I insert into table2 it inserts the date as:  23/01/2012 .... How do I correct this code so I can insert the date as:   23/01/2012 13:04:36 ????

\'G\' wrote:
Hi All,
I have a very simple select query as follows... UPLOAD_DATE is held in table1 in the following format:     23/01/2012 13:04:36
<cfquery name="test" datasource="test">
SELECT  UPLOAD_DATE
FROM     TABLE1
</cfquery>
and I loop around the above query to insert into another table...
<cfloop query="test">
     <cfquery name="make_tfer2" datasource="test">
          INSERT INTO TABLE2
               (UPLOAD_DATE)
          VALUES
               (#test.UPLOAD_DATE#)
     </cfloop>
</cfloop>
But, when I insert into table2 it inserts the date as:  23/01/2012 .... How do I correct this code so I can insert the date as:   23/01/2012 13:04:36 ????
Two suggestions (just to answer the immediate question):
1) Make sure the datatype of the column Upload_date in Table2 is datetime (not just date).
2) Try something like
<cfoutput query="test">
    <cfset date=dateFormat(parseDatetime(upload_date),"dd/mm/yyyy hh:mm:ss")>
    <cfquery name="make_tfer2" datasource="test">
        INSERT INTO TABLE2 (UPLOAD_DATE)
        VALUES #date#
    </cfquery>
</cfoutput>

Similar Messages

  • Find record insert date and time in a table

    Hi All,
    I want to get record insert date and time in a table. There is no datetime column in my table. Are there any possibility to get date and time for each record?
    Thank You

    Thats not easy. If your transaction info still resides on active portion of the log you can use fn_dblog to read out the time at which the transactions occurs. This is useful only if you try it shortly after transaction.
    the code would look like this
    SELECT *
    FROM fn_dblog(null,null)
    WHERE [Transaction Name] LIKE 'INSERT%'
    OR [Transaction Name] LIKE 'UPDATE%'
    Also see
    http://www.mssqltips.com/sqlservertip/3076/how-to-read-the-sql-server-database-transaction-log/
    http://solutioncenter.apexsql.com/read-a-sql-server-transaction-log/
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Insert date and time

    This is a simple question but one that has been bugging me in a small way. If on a spreadsheet I press 'insert date and time' all I get is that day and date for example saturday 10th July 2010 and no time.
    Anyone offer an explanation for this?
    Thanks
    Mike

    Hello Peggy
    The problem was already reported to Bugs Hunters :
    +Bug ID# 7862838.+
    +In Numbers and Pages there is the function+
    +Insert > Date Time.+
    +At this time, its default behaviour is : insert the current date and the time 12:00:00 (without displaying the time).+
    +Given my own experience and what is often asked in Discussions forums, it would be interesting to change the default setting so that it inserts the current date & time and display both of them.+
    +Of course some users wish the availability of three items:+
    +Insert > Date defaulting to the sole date component+
    +Insert > Time defaulting to the sole time component+
    +Insert > Date & Time defaulting to the complete current dateTime.+
    +I preferred the scheme defaulting with the complete current dateTime because removing one component is faster than adding one using the existing protocol.+
    Yvan KOENIG (VALLAURIS, France) samedi 10 juillet 2010 19:05:47

  • Unable to insert date and time when using date datatype

    Hi
    I am hitting a bit of a problem when using the date datatype. When trying to save a row to the table where the field it throws an error ora 01830 and complains about converting the date format picture ends...etc. Now when I do the insert, I use the to_date function with the format of "dd-mon-yyyy hh24:mi:ss". Of course, when I remove the time element, everything is perfect.
    Checking sysdate, I noticed that the time element wasn't be displayed, and I used alter session set nls_date_format to set the date and time I want to save to the table, which worked!
    Then based on advice in a previous thread to permanently fix the problem, I used alter system set nls_date_format ="dd-mon-yyyy hh24:mi:ss" scope=spfile; This showed that it was altered, and I can see the setting in the em. In sqlplus, I shutdown the database, and restarted with startup mount; alter database open; and then selecting sysdate, it still shows the date as dd-mon-yy, and still no time! Checking the em, and looking up the nls_date_format the setting is still shown as "dd-mon-yyyy hh24:mi:ss".
    So, my question is this - what am I doing wrong? Why can't save date and time using date in Oracle 11g?????
    Thanks

    user633278 wrote:
    Hi
    I am hitting a bit of a problem when using the date datatype. When trying to save a row to the table where the field it throws an error ora 01830 and complains about converting the date format picture ends...etc. Now when I do the insert, I use the to_date function with the format of "dd-mon-yyyy hh24:mi:ss". Of course, when I remove the time element, everything is perfect.
    Checking sysdate, I noticed that the time element wasn't be displayed, and I used alter session set nls_date_format to set the date and time I want to save to the table, which worked!
    Then based on advice in a previous thread to permanently fix the problem, I used alter system set nls_date_format ="dd-mon-yyyy hh24:mi:ss" scope=spfile; This showed that it was altered, and I can see the setting in the em. In sqlplus, I shutdown the database, and restarted with startup mount; alter database open; and then selecting sysdate, it still shows the date as dd-mon-yy, and still no time! Checking the em, and looking up the nls_date_format the setting is still shown as "dd-mon-yyyy hh24:mi:ss".
    So, my question is this - what am I doing wrong? Why can't save date and time using date in Oracle 11g?????
    ThanksYou most certainly can save the time. A DATE column, by definition stores date and time. What you describe is a presentation problem, and setting nls_date_format at the system as an init parm is the weakest of all settings as it is overridden by several other locations.
    without seeing the exact sql that produced the error (not just your description of what you think you were doing) it is impossible to say for sure.
    However, I'd suggest you read http://edstevensdba.wordpress.com/2011/04/07/nls_date_format/

  • Insert date and time into write to spreadsheet

    Easy question here
    I need save 4 arrays of data and insert the date and time that it was taken (LV 8.6)
    for example
    9/4/09 10:00:01 AM  4  6  7  2
    9/4/09 10:00:02 AM  4  6  7  2
    9/4/09 10:00:03 AM  4  6  7  2
    9/4/09 10:00:04 AM  4  6  7  2
    Any ideas, I can't wire the timestamp or date/time string right into the create array
    Thanks
    Chris
    Solved!
    Go to Solution.

    Ok
    the basic problem that I see is the the LabVIEW TimeStamp type is a cluster.  Converting it to a dbl gives you a value in seconds elapsed since 1904 Jan 1 12:00AM GMT and, your spreadsheet cannot interprate that (or display that) as a "TIME."   So, you want to convert it to a string (easy TS->String check the help for format options) BUT, you might want to pass all of your data as numbers into your spreadsheet so you can post-calculate or graph other outputs vs. TIME!  This little chunk of code .....
     converts a LV Timestamp to a number that Excel interperates as "the amount of days elapsed since 0 Jan 1900 @ 12:00AM LOCAL."  You will need to format the cell in Excel to display it as a date-time But it can be operated on and graphed against with only Excel's limitations (Excel followed the Lotus bug of erroneously assuming 1900 was a leap year, and Leap seconds are unrecognized)
    Enjoy!
    Message Edited by Jeff Bohrer on 08-06-2009 02:28 PM
    Jeff

  • Insert Date and Time doesn't update

    i am inserting a date and time in my numbers documents so that i know which paper copy is the most current. i do this by going to Insert pulldown and selecting Data and Time while in a Footer Cell.
    this data does not update upon re-opening the file and i end up printing multiple copies over weeks and months with simply the date that I inserted the Date and Time into the footer.
    is there a way to do this so that it updates?
    TIA

    As most of the times,
    this kind of question is answered in Numbers User Guide.
    When you insert a date_time value in a cell, you insert a fixed value.
    If you want a living one, you must insert a formula.
    =NOW()
    or
    =TODAY()
    would achieve your goal.
    Yvan KOENIG (VALLAURIS, France) dimanche 25 décembre 2011 21:40:50
    iMac 21”5, i7, 2.8 GHz, 12 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.2
    My iDisk is : <http://public.me.com/koenigyvan>
    Please : Search for questions similar to your own before submitting them to the community

  • Inserting Date AND Time using DBMS_XMLStore.insertXML

    Hello,
    I'm using a c# app to create an xml file to be passed to a stored procedure. The store procedure then uses DBMS_XMLStore.insertXML to insert the record in the xml file into the database.
    There is a field in the Oracle table called "ENTER_DATE". I've been putting a date into the xml file for this field (ie. "10-mar-2010") and this has worked fine. However, I've now been asked to include the time with the date.
    Is it possible to somehow put a date AND time value in the xml tag value so that DBMS_XMLStore.insertXML will properly insert it into the Oracle table? Everything I try returns a date picture format error.
    Thanks

    SQL> create table dept2
    as
       select d.*, sysdate enter_date
         from dept d
        where 1 = 2
    Table created.
    SQL> select * from dept2
    no rows selected.
    SQL> alter session set nls_date_format='dd.mm.yyyy hh24:mi:ss'
    Session altered.
    SQL> declare
       ctx   dbms_xmlstore.ctxtype := dbms_xmlstore.newcontext ('dept2');
       doc  xmltype
          := xmltype('<START>
                   <ROW>
                     <DEPTNO>10</DEPTNO>
                     <DNAME>ACCOUNTING</DNAME>
                     <LOC>NEW YORK</LOC>
                     <ENTER_DATE>10.10.2010 23:11:16</ENTER_DATE>
                   </ROW>
                         </START>');
       ret   int;
    begin
       ret := dbms_xmlstore.insertxml (ctx, doc);
       dbms_xmlstore.closecontext (ctx);
    end;
    PL/SQL procedure successfully completed.
    SQL> select * from dept2
        DEPTNO DNAME          LOC           ENTER_DATE          
            10 ACCOUNTING     NEW YORK      10.10.2010 23:11:16 
    1 row selected.

  • How do I insert date and time in my DB?

    Hi!
    I 'm trying to make an application that the user enters some information (name, address...) and I also have a field where the user must enter date and time. But I don't know how to insert it to the database (MS Access). How can I convert a string into a date or time object in order to insert it to the db?
    I am new in programming with databases.
    Thanks in advance.

    Look at the following...
    java.sql.PreparedStatement (particularly the setDate, setTimestamp etc methods)
    and look at
    java.text.SimpleDateFormat

  • Inserting Date and Time into a date field

    Okay I am a bit of a Oracle newbie. I am trying to insert the following date and time into a date field and I don't know how to format the second part of the to_Date() function.
    Date/Time: 5/29/2003 7:58:45 PM
    Thanks,
    Branden

    I believe you would want
    to_date( '5/29/2003 7:58:45 PM', 'MM/DD/YYYY HH:MI:SS AM' )
    Note that tahiti.oracle.com has all of Oracle's documentation, including the very useful SQL & PL/SQL reference manuals, available for free.
    Justin

  • Time Machine: Mavericks backup date and time issues

    Time Machine: Troubleshooting backup issues
    re:  http://support.apple.com/kb/HT3275
    "Messages you may see after clicking the red "i" include:"
    I am getting a message not listed at this page. My Time Machine fails to backup to my USB3 Passport External Drive with the error code: 
    "Time Machine couldn't complete the
    backup to "2T PP".
    The system date and time is incorrect."
    I have the Date & Time preference set to:
    "√ Set date and time automatically:  Apple Americas/U.S. (time.apple.com)"
    and it seems to be the correct time.
    The Language & Region prefs, advanced, Dates tab is set to defaults but I cannot get TM to backup and the same error occurs.
    How can I remedy this?

    Because you have just loaded a new operating system and a complete backup occurs is my understanding.

  • Help please on inserting date and time on iWeb

    I am using iWeb '09 (which I love) to manage the website for our HomeOwners Assocation.
    http://www.seabridgehh.com/seabridgehh.com/Home.html
    I have downloaded a script to insert the current date and time - which works, but............
    has anyone got a clue on how to re-format the font and colour please?

    Julian:
    This demo page has examples of date and time added to a page. The text versions are not self updating. The embedded flash version is. There may be a way to have the text version update every second or minute depending on what you have displayed but I've not found it in my searches to date:
    OT

  • HT203483 Date and time issue in iPhone 5c

    I have update with latest firmware but date and time proble not solved

    Hello komalsingh235,
    If I understand correctly your phone is not automatically getting the correct date and time. Use these steps from the following article. If the troubleshooting does not correct it, then it also has a resource for you to get additional support:
    iOS: Troubleshooting issues with date and time
    If the option to enable date and time automatically is available, turn it on. Tap Settings > General > Date & Time.
    Ensure that your time zone is set up correctly. Tap Settings > General > Date & Time > Time Zone.
    If the incorrect date, time, or time zone is being set up automatically on the device, please notify your cellular provider. In the meantime, tap General > Date & Time and turn off Set Automatically. Then set the appropriate time and time zone manually.
    Thank you for using Apple Support Communities.
    All the best,
    Sterling

  • Date and Time Issue for Mult Org...

    Hello,
    How can I manage the date time, if my organizations have different plant and location?
    I.e. The database server located in Pacific Time zone and the application may access from new plant German time zone.
    Whenever the German business center enters any sales transaction it should take German current date and time instead of Pacific Time.
    Pls advice me
    Thanks,Raghu.K

    Hi,
    While defining a Location, you can mention the time zone for that location and also the inventory organisation to which this location belongs.
    So, this location can be assigned to your organisations. You can access the time zone according to the location you select.
    regards

  • Date and Time Issues

    Recently, my iPod touch 2G has been reverting to a different date and time from the actual. The time zone is set on eastern time (Atlanta USA) but it keeps changing the date to February 8, 2009 and 11:09PM. Even after I change it in general settings, it goes back to the other after time.
    Any ideas?

    I've heard about this little bug and it has happened to me on a few occasions.
    Apparently, it appears when you put your PC to sleep when iTunes is open. So when you resume from Sleep Mode, make sure you close iTunes, then connect your iPod or re-open iTunes.

  • Date and Time Issue.

    I have date and time with different format , Need in Single date and Time format.
    Input
    13/03/15 09:09
    13/03/15 07:39
    13/03/15 08:09
    13/03/15 08:51
    3/13/15 09:39:14 AM
    3/13/15 09:38:14 AM
    3/13/15 09:37:59 AM
    3/13/2015 09:37:59 AM
    Problem with the below Output
    01/01/01 12:00 AM
    01/01/01 12:00 AM
    01/01/01 12:00 AM
    01/01/01 12:00 AM
    13/03/15 09:39 AM
    13/03/15 09:38 AM
    Output required in the below format for all of the above date and Time with proper date & time
    13/03/15 09:39 AM

    Indudhar,
    I don't know if the following will help or not, but hopefully you can see what I'm doing and modify it to give you the string format of the DateTime the way you want it:
    ption Strict On
    Option Explicit On
    Option Infer Off
    Public Class Form1
    Public Enum DateTimeFormat
    LongDateLongTime
    LongDateShortTime
    ShortDateLongTime
    ShortDateShortTime
    LongDateOnly
    ShortDateOnly
    LongTimeOnly
    ShortTimeOnly
    End Enum
    Private Sub Form1_Load(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) _
    Handles MyBase.Load
    ' Test it here...
    Stop
    End Sub
    Private Function GetFormattedDateTimeString(ByVal dt As DateTime, _
    ByVal formatType As DateTimeFormat) As String
    Select Case formatType
    Case DateTimeFormat.LongDateLongTime
    Return String.Format("{0} {1}", _
    dt.ToLongDateString, _
    dt.ToLongTimeString)
    Case DateTimeFormat.LongDateOnly
    Return dt.ToLongDateString
    Case DateTimeFormat.LongDateShortTime
    Return String.Format("{0} {1}", _
    dt.ToLongDateString, _
    dt.ToShortTimeString)
    Case DateTimeFormat.LongTimeOnly
    Return dt.ToLongTimeString
    Case DateTimeFormat.ShortDateLongTime
    Return String.Format("{0} {1}", _
    dt.ToShortDateString, _
    dt.ToLongTimeString)
    Case DateTimeFormat.ShortDateOnly
    Return dt.ToShortDateString
    Case DateTimeFormat.ShortDateShortTime
    Return String.Format("{0} {1}", _
    dt.ToShortDateString, _
    dt.ToShortTimeString)
    Case DateTimeFormat.ShortTimeOnly
    Return dt.ToShortTimeString
    Case Else
    Return String.Empty
    End Select
    End Function
    End Class
    I hope that helps. :)
    Still lost in code, just at a little higher level.
    No Frank, Same Problem.....Kindly help me  X1 = 14/03/15 19:30
    I need time Diff of now and X1
    Dim myDateTime As DateTime = GetFormattedDateTimeString(X1, DateTimeFormat.ShortDateOnly)
    myDate = myDateTime.ToString("dd/MM/yy")
    myTime = myDateTime.ToString("hh:mm tt")
    Dim myDateTime1 As DateTime = Now
    Dim myDate1 = myDateTime1.ToString("dd/MM/yy")
    Dim myTime1 = myDateTime1.ToString("hh:mm tt")
    Dim diff As TimeSpan = myDateTime1.TimeOfDay - myDateTime.TimeOfDay
    Dim diffString As String = String.Format("{0:00}:{1:00}:{2:00}", _
    Math.Abs(diff.Hours), Math.Abs(diff.Minutes), Math.Abs(diff.Seconds))

Maybe you are looking for