How to put date&time into a variable from a database?

In an Oracle table, myDateColumn is 2002-06-25 17:40:55. I can't put it into a variable.
java.text.SimpleDateFormat dF=new java.text.SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
rs=stmt.executeQuery("select myDateColumn from myTable");
rs.next()
System.out.println(rs.getString(1)); // 2002-06-25 17:40:55 is output
java.util.Date myDate=rs.getDate(1);
out.println(dF.format(myDate)); // 25/06/2002 00:00:00 is output
java.util.Date myDate=rs.getTime(1);
out.println(dF.format(myDate)); // 01/01/1970 17:40:55 is output
My question is: How should I put this date (both date and time) into a variable, myDate?

There are three JDBC types relating to time:
1] The JDBC DATE type represents a date consisting of day, month, and year. The corresponding SQL DATE type is defined in SQL-92, but it is implemented by only a subset of the major databases. Some databases offer alternative SQL types that support similar semantics.
2] The JDBC TIME type represents a time consisting of hours, minutes, and seconds. The corresponding SQL TIME type is defined in SQL-92, but it is implemented by only a subset of the major databases. As with DATE, some databases offer alternative SQL types that support similar semantics.
3] The JDBC TIMESTAMP type represents DATE plus TIME plus a nanosecond field. The corresponding SQL TIMESTAMP type is defined in SQL-92, but it is implemented by only a very small number of databases.
In ur case pls use:
java.sql.Timestamp
good luck !
...san :--)

Similar Messages

  • PDF: How to get date/time into the heading of a FOP/PDF file?

    Hi!
    What changes do I need to make to the PDF report template or what else can I put in the heading block of the "Print" page so that it will include the date and time the PDF was generated?
    Also how would I add this so that it prints on the bottom of the page like the page number?
    Thanks in advance for any tips, tricks, ideas, examples, etc.!
    Dave Venus

    Hi!
    Perhaps I missed this some place but you can get the value of a page item or application item into the header or footer of a (FOP) PDF report by using a "&<item>." format substitution string. For example I have a 1 time application process that puts todays date in an application item named F106_SYSDATE (F106_ is the application id). Then in my headers I use:
    XXXX Report on: &F106_SYSDATE.
    Simple. Works great! And better yet my users are a little happier! :)
    Thank for everyone's help and suggestions!
    Dave Venus

  • How to put data into a RFC import parameter structure from portal

    Hi, All,
    I have a RFC in which an import parameter is a structure (not a table). I want to put data into that structure. I know how to put data into a table or a string. I tried to use
    IRecordSet MyTABStr = (IRecordSet)structureFactory.getStructure(function.getParameter("MYTABSTR").getStructure());
    MyTABStr.setString("FIELD1", value1);
    MyTABStr.setString("FIELD2", value2);
    importParams.put("MYTABSTR",MyTABStr);
    But it works for table not structure.  Is there anybody know how to do that?
    Thanks in advance!
    Meiying

    Hi,
    You can try the following code -
    IRecord structure = (IRecord)structureFactory.getStructure(function.getParameter("MYTABSTR").getStructure());
    structure.setString("FIELD1", value1);
    structure.setString("FIELD2", value2);
    importParams.put("MYTABSTR",structure);
    Regards,
    Sudip

  • How ti save date/time info into .lvm

    Hi,
    i need to save date/time info (Date:Time) into one .lvm together with my other signals (dynamic data). any suggestions?
    it should look like this for example
    results.lvm:
    date/time signal 1 signal 2 signal 3
    01.01.2005/12:00 2.2 3.3 4.4
    01.01.2005/12:02 2.4 3.4 4.5
    01.01.2005/12:04............
    and so on for every loop.
    thanx in advance
    vedran divkovic

    The LVM Express VI was designed to be easy to used. To facilitate this, data formats are fixed and cannot be set by the user in the Express VI. You have several options to get the format you want.
    If you don't need all the header information in the LVM file, roll your own code. If you are only saving one line of code at a time, this is particularly easy. You will also need to write your own read code, assuming you are not just using Excel or something similar.
    Use the formatting capabilities of your analysis program to create the date code. Excel, for example, is perfectly happy to generate a time/date string based on a simple number. You may have to convert from LabVIEW absolute time to Excel absolute time, but that is fairly trivial. You can make a macro to do this.
    If you need the LVM header info, write the file using no data to get the header, then fill in your data with your own formatting. Read-back will be harder, since you will need to write that yourself. However, you can probably get most of the info from the LVM file read (maybe with an error), then read your own formatted data from the end of the file.
    WARNING: this one dives into vi.lib code. While you cannot change the formatting in the top level of an LVM file, the subroutines do take formats on a per-column basis. So, you can modify the original code to do what you want. Open the front panel, then search for ex_SignalsToSprdsheetStr.vi. Give it the format string you want and you are off. Note that this format will be in place everywhere you use the LVM code unless you save the entire hierarchy to a different location (using Save With Options->Development Distribution, include vi.lib files). Be very careful with this. You can easily get into cross-linking problems (linking VIs from the wrong location).
    One final comment. You can find the specification for the LVM file format in Specification for the LabVIEW Measurement File (.lvm), Version 1.0. It includes everything you didn't want to know about the LVM file format.
    This account is no longer active. Contact ShadesOfGray for current posts and information.

  • How to put measures correctly into spreadsheet

    Hi expert,
         I loaded data into a planning model, and I can see data in BW and BEX, but when I put 'ACCOUNT' into row, and 'TIME' into column, I can't see 'measures' in spreadsheet, eventhough I drag 'measures' into spreadsheet from EPM pane, then update, getting blank for 'measures', it is gone. please tell me how to put measures correctly into spreadsheet.

    P.S If you are creating report by drag n drop on EPM pan, then same way need to add measure dimension in desired axis.
    Share the screen shot.
    Shrikant

  • How to print date/time in report page footer?

    Hi
    I have a report which users can print as PDF.
    However, I like to display current date/time in report footer.
    I can see the Page Footer in section but can't figure out how to print date/time there.
    Thanks for help.

    hi movilogo
    Please try this.
    Create hidden item P1_DATE
    Create On load process in page 1 and put this code
    begin
    :P1_DATE:=TO_CHAR(SYSDATE,'DD-MON-YYYY HH:MM:SS');
    end;
    Open your region in Page 1 put this code in Footer area
    *&P1_DATE.*
    Refresh your page.
    you will get the output like this.
    16-SEP-2009 11:09:17
    thanks
    Mark Wyatt

  • How to  use data function using characterstics variable for calculation on

    how to  use data function using characterstics variable for calculation on  attribute as key figure

    Hi Gayatri
    Did you not see my answer for CASE because CASE does indeed offer the use of the BETWEEN clause, but DECODE does not. Let me give you a little synopsis of DECODE.
    In its most simple form it takes 4 values and looks like this: DECODE(A, B, C, D)
    This essentially means, IF A = B THEN C ELSE D
    The trick to solving BETWEEN in a DECODE is to work out algoriths where A = B. Because we don't know how many values are between 00 and 99, although I could guess there were 100 we could of course have 100 parts in the DECODE but that would be awful. How about if we look at it another way and say this:
    IF PART_NUMBER < 'SDK00' THEN pay_amount
    ELSE IF PART_NUMBER > 'SDK99' THEN pay_AMOUNT
    ELSE pay_amount + 100
    This statement only had 2 hard coded values, but how to make DECODE work with less than? Easy, we use the LEAST function. The LEAST function takes 2 values and returns the one with the lowest value. So I use LEAST(PART_NUMBER, 'SDK00') then whenever the PART_NUMBER is lower than SDK00 it will be true. A similar situation exists for the opposite function GREATEST. Putting all of this together then, you can do this:
    DECODE(PART_NUMBER, GREATEST(PART_NUMBER, 'SDK00'), DECODE(PART_NUMBER, LEAST(PART_NUMBER, 'SDK99'), PAY_AMOUNT * 100, PAY_AMOUNT), PAY_AMOUNT)
    In English this can be read as follows:
    IF the PART_NUMBER is greater than or equal to SDK00 and the PART_NUMBER is less than or equal to SDK99 THEN PAY_AMOUNT x 100 ELSE 0
    Best wishes
    Michael

  • Inserting logon date & time into a table

    hi,
    i want to insert the logon date&time into a table which have a field
    called log_track and data type as date. i want to insert the
    information as 'dd/mm/yyyy hh24:mi:ss' . I tried to insert with
    the follwoing
    insert into log_chek values ( to_date(sysdate,'dd/mm/yyyy hh24:mi:ss))
    but it is not taking the time...how to include the time also..? I am using oracle 8i
    thanks in adv
    kris

    Dates are stored as dates. You cannot select to store a date in date format like dd/mm/yyyy hh24:mi:ss. That is not your decision to make. It is stored as a date format as a binary value.
    How you want to view that date, is your decision. How must this binary date format value much be displayed as a text string?
    So, when inserting a date you insert it as a date. That simple.
    insert into log_chek values ( sysdate )
    When you want to view that date, you decide how you would like it to be displayed in human readable format:
    select TO_CHAR( log_date, 'dd/mm/yyyy hh24:mi:ss') as log_date from log_chek

  • How to put datas from database in html�s forms?

    Does anyone have any idea how to put datas from the database using JSP???

    One option: put your data into a JavaBean and then put that into the session. You can then access it from your JSP. You can access the properties of the bean using the basic JSP scripting elements, or if you want to get fancy, both JSTL and Struts have a bunch of custom tags for working with JavaBeans.

  • Boss is gonna kill me. I Need help inserting a DATE/TIME into MSAccess

    Hello,
    I have spent way to long trying to figure out how to insert a date into the date/time field of a microsoft access database. Could someone please help me figure this out. I know there are a million previous posts about this topic and i looked through a bunch and none of them seem to work... i have tried so many different things. The code i am working (at this point in time.. since it has changed a million times) is:
                             String MYDATE = "yyyy-MM-dd hh:mm:ss a";
                             Date date = new Date();
                             String dateout = new SimpleDateFormat(MYDATE).format(date);
                             System.out.println(" the date is " + dateout);
    Timestamp timeStamp = new Timestamp(date.getTime());
    timeStamp.setNanos(0);
                             System.out.println(" the date is " + timeStamp);
                             String sql2 = "INSERT INTO DATE5 (stuff, date) VALUES ('hello', CVDATE(" + timeStamp + "))";
                             ProblemTrackingDB.DoUpdate(sql2);
                             sql2 = "INSERT INTO DATE5 (stuff, date) VALUES ('hello', '" + dateout + "')";
                             ProblemTrackingDB.DoUpdate(sql2);
    i have tried both of those ways and either work (ie... comment one out and try the other)
    i always get a " Syntax error in INSERT INTO statement" thrown
    i have also tried without the single quotes.
    Any help would Be MUCH appreciated as my boss is starting to get agrivated...
    thanks to anyone who helps,
    Jon

    Change your program to use a PreparedStatement to do this insert. You only need to create a PreparedStatement once, so in your constructor or initializer do this:PreparedStatement insert = connection.PrepareStatement("INSERT INTO DATE5 (stuff, date) VALUES (?, ?)");Then the code to write a record is this:Timestamp timeStamp = new Timestamp(date.getTime());
    timeStamp.setNanos(0);
    insert.setString(1, "hello");
    insert.setTimeStamp(2, timeStamp);
    insert.executeUpdate();That's all. You never need to mess about with formatting timestamps in the way your database needs them, the PreparedStatement takes care of all that for you.

  • How to print date & time stamp on photos?

    How to print date & time stamp on photos?

    Three methods:
    File>process multiple files>labels. Be sure to uncheck "same as source", or the originals will be overwritten. It is best to work on duplicate files, esp. while learning.
    Use the horizontal or vertical type tool to add the information manually to each picture file
    If the same information is to be applied to several pictures, e.g. a copyright notice, use  of a brush made in PSE is very efficient

  • Insert a value of type Date/Time into a database

    I am trying to insert a value of type date time into an access database. What is the format needed to insert the date/time.
    Thanks,
    -Amos

    I had all kinds of problems getting a datetime inserted into a SQl Server DB. Probably similar so this is what I do:
    String date = new String("01/01/97 12:00:00");
    stmt.setObject(1, date);
    I tried using TimeStamp's but found I got an occasional Fractional Truncation exception back from the driver. Never had a problem inserting a String using the setObject() method though.
    Hope this helps

  • How to put html file into a canevas?

    How to put html file into a canevas?

    Hi,
    would require you to write a JavaBean that interprets the HTML (there are commercial versions of this available)
    Frank

  • How to put selected videos into one place (File)

    How to put selected videos into a File so I can only show on TV the videos in that file

    YYou have to describe your issue in more detail. Are you using iTunes? Trying to see it in Apple TV, etc, etc.

  • How to convert Date format into day in ssrs reports?

    Hi
    How to convert date format into day?
    10/01/2010 as like Monday like that?

    =weekdayname(datepart("w",Fields!mydate.Value))
    -Vaibhav Chaudhari

Maybe you are looking for

  • Need help fom my imac, monitor impression?

    it is almost running out my imac apple care, and in some light condition it seems to me to se the dock on boot screen... but if i use a white background and maximum brightness i can't always see it i can't really tell what can be, but my options are.

  • Portal Runtime Error when trying to preview an iView

    Hi All,               I am getting the following exception when I am trying to preview an iView (created from a par file I did some settings like rt_Parameter ) Portal Runtime Error An exception occurred while processing your request Exception id: 02

  • Installing PS error 49.

    I have just subscribed to Photographers Pack. Lightroom installed OK but photoshop brings up error 49 - components missing. When retrying same message. Please any ideas?

  • No 4G connectivity option using Wind GR

    Hello to all! I am a happy owner of a BlackBerry Z30 smartphone. Few days now Wind mobile operator here in Greece provides 4G connectivity but unfortunately i can't have that on my Z30.. Below you will find few details that might be important: - Mode

  • Registering 2nd copy problem

    I have Acrobat X Pro bought 2011. I want to run on 2nd machine. Installed from original install .exe. Entered serial # in process. Won't run except as a trial. Entering serial in trial input popup  causes request for qualifying product. Help shows no