Casting a date type into sql.date

Hi there ...I trying to cast this sentences...please help me out...thanks
sentencia.setInt(4,Integer.parseInt(request.getParameter("FECHA_INICIO")));
sentencia.setInt(5,Integer.parseInt(request.getParameter("FECHA_FIN")));
both of them are date and the values wii go into a database on oracle...im working wuth jsp too..

If you need to insert a date, why are you creating an int from a string and using setInt()?
Create your Date object from the request parameters and use setDate() instead.

Similar Messages

  • How to create longtext or blob data types in SQL using labview

    Hello,
    I am fairly new to SQL, and I'm using the labview database connectivity toolset.  Using labview 6.1
    I am using the DB Tools Create Table vi to create my tables.  I want the tables to hold 1000 character strings.  But the longest string that I can insert seem to be 255 characters.  I think It is a limitation of the "String" data type in SQL so I need to use text or blob types.  The problem is I created a control for the "Column Information" field and I see the following selections for the data type. (String, Long, Single, Double, date/time, binary).  I dont see any selection for text or blobs.  How do I define another data type that is not part of the selection in the control?
    Thanks for any help.

    I don't know about defining long text, but the equivalent of a BLOB should be the binary data type, which just holds the data you put into it without formatting it.
    Try to take over the world!

  • Dealing with the DATE data type in SQL Server

    As you know, a date is stored in SQL Server as "yyyy-mm-dd" when using the DATE data type.  This is also how it displays when I pull it into my Access front-end (even if I set the field's format to Short Date.)
    I'd like to be able to display it based on the user's regional settings.  I know I can use the FORMAT method in VBA to change it to mm/dd/yyyy, but I have users in other countries and I don't want to have to maintain a number of different versions.
    Any idea how I can automatically display the date in my MS Access form based on the user's regional settings?
    Thanks.

    Your solution, however, does not address the root of the problem. Access thinks it is a text field because there is no such thing as a 'Date' data type in Access. You will run into problems anywhere in Access, that you expect it to perform as
    a Date/Time field. E.G. sorting, filtering. 'Date' is one of the newer data types in SQL Server 2008+. You should be using SQL Server DateTime or SmallDateTime data type. Access will recognize those as a Date/Time data type and treat them accordingly.

  • OpenSQLException - object of type java.sql.Date is not normalized

    Hi,
    I am attempting to code an SQL query in an EJB and get the following exception:
    com.sap.sql.log.OpenSQLException: The object of type java.sql.Date with the value '2010-06-04 13:21:09.424' assigned to host variable 1 is not normalized. It must not contain time components in the time zone running the virtual machine. at com.sap.sql.log.Syslog.createAndLogOpenSQLException(Syslog.java:85) at com.sap.sql.log.Syslog.createAndLogOpenSQLException(Syslog.java:124) at com.sap.sql.jdbc.common.CommonPreparedStatement.setDate(CommonPreparedStatement.java:650) at......
    Below is the code snippet I am using:
                        private static String selWQ  = "Select * from ZZZZ_TABLE " +
                                                                       "where DATEFROM >= ? " +
                                                                  "and DATETO <= ? ";
         public UsageRecord[] getRecords(Date fromDate,Date toDate)
              UsageRecord[] ura = null;
              String q          = null;
              ArrayList al      = new ArrayList();
              try
                   q = selWQ;
                   conn.open();
                   PreparedStatement p = conn.prepareStatement(q);               
                   p.setDate(1, fromDate);
                   p.setDate(2,toDate);                    
                   ResultSet rs = p.executeQuery();
    I have a PreparedStatement and am using setDate to set the values. The fromDate and toDate parameters are of type java.sql.Date
    Can someone please tell me what I am doing wrong and how to fix it?
    thanks
    Brian

    As requested, here is an example of what I used to resolve this:
                   PreparedStatement p = conn.prepareStatement(q);
                   SimpleDateFormat ddf = new SimpleDateFormat("yyyy-MM-dd");
                                               String sFrom = ddf.format(new java.util.Date(fromDate));
                   String sTo   = ddf.format(new java.util.Date(toDate));
                   p.setDate(1, java.sql.Date.valueOf(sFrom));
                   p.setDate(2, java.sql.Date.valueOf(sTo));
                   ResultSet rs = p.executeQuery();
    fromDate and toDate are parameters of type long...
    regards
    Brian

  • Store values of different data types into single database field

    Hi Friends,
      I  have to store values of different data types(character, numeric, date, time,  text, etc) into a single database field(Char 80). Then read the same values and display it into ABAP Webdynpro report. 
    Appreciate any ideas, examples, suggestions.
    Thanks
    JB

    Hi,
    Try like this:
    data: txt1 type string,
          var1(1) type c,
          var2(1) type n,
          var3 like sy-datum,
          var4 like sy-uzeit.
    parameters: a type c,
                b type n,
                c like sy-datum,
                d like sy-uzeit.
    concatenate a b c d into txt1.
    write txt1.
    var1 = txt1+0(1).
    var2 = txt1+1(1).
    var3 = txt1+2(8).
    var4 = txt1+8(8).
    write: / var1,
           / var2,
           / var3,
           / var4.
    Regards,
    Bhaskar

  • How to Get Default Value of a Data Type in SQL Query.

    Hi all,
    I am creating a procedure which will take input the table name and Column Name.
    In the Output i would like to have the data type and default value of that data type which will be used by a another procedure to blank the selected column in the database.
    I tried with SET NULL on the column but as the database is of navision the table have property set to NOT NULL.
    Here is what i have done till now.
    Create Procedure Get_Column_type
    @parm_table_name nvarchar(200),
    @parm_column_name nvarchar(20),
    @parm_result nvarchar(20)OUTPUT
    AS
    BEGIN 
    select @parm_result =
    DATA_TYPE from INFORMATION_SCHEMA.COLUMNS IC
    where TABLE_NAME = '[' + @parm_table_name +']' and COLUMN_NAME = '[' + @parm_column_name + ']'
    END
    GO
    Now instead on write a case statement for so many data types in SQL, i was thinking is it possible someway that above procedure also returns the default value which i can set in another procedure.
    Let me know if its possible or not? Thanks in advance.

    Do you looking for something like this?
    create table t10 ( c int default 1)
    SELECT so.name AS table_name, 
              sc.name AS column_name, 
              sm.text AS default_value
         FROM sys.sysobjects so
         JOIN sys.syscolumns sc ON sc.id = so.id
    LEFT JOIN sys.syscomments SM ON sm.id = sc.cdefault
        WHERE so.xtype = 'U' 
          AND SO.name = 't10'
     ORDER BY so.[name], sc.colid
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Sql Loader loading separate date parts into a date

    Hello,
    I'm having a question on SQL Loader.
    Suppose I have a flat file with a format:
    "John Jackson", 2007, 12, 31, 23, 59, 01
    "William Smith", 2007, 12, 31, 23, 59, 02
    "Tracy vanDijk", 2007, 12, 31, 23, 59, 03
    And I like to put it in a table TEST with (name varchar(20), mydate date).
    The problem is: how to create a control file for sqlLoader that converts the seperate date-elements into a date field?
    load data
    infile 'mydata.csv'
    badfile 'badfile.log'
    discardfile 'discardfile.log'
    append
    into table TEST
    fields terminated by "," optionally enclosed by '"'          
    ( name, mydate ????)
    I'd like to put it in one step into a date field, and not using seperate tables, stored procedures, triggers and such. I think it must be possible, but I wasn't able to find a working example thus far.
    Hope you can help me out.

    A colleague came up with the BOUNDFILLER option. Searching again on the forum I created the solution, that I'd like to share with you.
    SQL> create table TEST1 (naam varchar(30), meetdatum date);
    Tabel is aangemaakt.
    mydata.csv:
    "Scott Tiger", 2006, 02, 18, 23, 59, 4
    "Frank Naude", 2007, 12, 31, 18, 00, 59
    "Fou TeDatum", 2007, 02, 31, 01, 10, 5
    "Johnny Smith", 2007, 1, 1, 12, 00 , 00
    laden.ctl:
    load data
    infile 'mydata.csv'
    badfile 'badfile.log'
    discardfile 'discardfile.log'
    into table test1
    fields terminated by "," optionally enclosed by '"'     
    trailing nullcols     
    ( naam
    ,b_yyyy boundfiller char
    ,b_mm boundfiller char
    ,b_dd boundfiller char
    ,b_hh24 boundfiller char
    ,b_mi boundfiller char
    ,b_ss boundfiller char
    ,meetdatum "to_date(:b_yyyy || :b_mm || :b_dd || :b_hh24 || :b_mi || :b_ss , 'YYYYMMDDHH24MISS')"
    SQL> alter session set nls_date_format = 'YYYY-MM-DD:HH24:MI:SS' ;
    SQL> select * from test1;
    NAAM MEETDATUM
    Scott Tiger 2006-02-18:23:59:04
    Frank Naude 2007-12-31:18:00:59
    Johnny Smith 2007-11-12:00:00:00
    The wrong date, Feb 31st, is spooled to the badfile.

  • I am unable to add Data element into existing Data Type

    Hi Experts,
    I am unable to add Data element into existing Data Type, It shows disable mode, suggest me this..
    Thanks

    Yep got it...
    Edited by: Manoj on Aug 20, 2008 1:09 AM

  • User exit for adding more date types into IT0041

    Hi all,
    I have a requirement where in HCM infotype IT0041 I need to add couple more custom date types besides standard date types in IT0041. So if I use user exit, what are the steps to do this? what enhancement name should be used?
    Thanks,

    Ben - Unfortunately I haven't implemented a BAdI as I do more functional work.  I found a few documents on line that may help (gotta love Google!).  Maybe someone on SDN who is more technical can provide additional information.
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/d0456c54-0901-0010-f0b3-cd765fb99702?quicklink=index&overridelayout=true
    http://sapient.wordpress.com/2007/05/25/implementing-business-add-ins-badi/
    http://it.toolbox.com/wiki/index.php/Document_on_BADI#BADI_Implementation
    Good luck!
    Thanks,
    Danialle

  • Cannot convert from java.util.Date to java.sql.Date

    In the below code am trying to get the current date and 60 days prior date:
    Date  todayDate;
              Date  Sixtydaysprior;
              String DATE_FORMAT = "MM/dd/yy";
              DateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
             Calendar cal = Calendar.getInstance();
              todayDate = sdf.parse(sdf.format(cal.getTime()));
              cal.add(Calendar.DATE, -60);
             Sixtydaysprior = sdf.parse(sdf.format(cal.getTime()));I have imported following files:
    <%@page
         import="java.util.Calendar,
                   java.text.SimpleDateFormat,
                   java.text.ParseException,
                            java.util.*"
    %>Shows up following error msg:
    Type mismatch: cannot convert from java.util.Date to java.sql.Date
    Thanks.
    Edited by: MiltonDetroja on May 22, 2009 11:03 AM

    Shows up following error msg:
    Type mismatch: cannot convert from java.util.Date to java.sql.Date
    I don't think this exception is thrown from the portion of code you have shown. As clearly specified in exception message, you cannot cast an instance of java.util.Date to java.sql.Date. you will need to do something like this
    java.util.Date today = new java.util.Date();
    long t = today.getTime();
    java.sql.Date dt = new java.sql.Date(t);

  • Disallowed implicit conversion from data type datetime to data type timestamp

    Received error: [Macromedia][SQLServer JDBC
    Driver][SQLServer]Disallowed implicit conversion from data type
    datetime to data type timestamp, table 'myTbl', column 'duration'.
    Use the CONVERT function to run this query.
    I have a field named duration hh:mm:ss.lll that I am trying
    to insert into MS SQL. DB has field defined as [duration]
    [timestamp] NOT NULL,
    My insert has this: INSERT INTO myTbl( duration) VALUES(
    <cfqueryparam value="2006-05-26 11:12:13"
    cfsqltype="CF_SQL_TIMESTAMP"/> )
    Why does this not work? rrrrrrrrrrrrrr! BTW: also tried with
    seconds as 13.111 which did not work. Does the db duration need to
    be date? I just want to store a duration for the time of a movie...
    10 Q

    quote:
    Originally posted by:
    quiet1
    Received error: [Macromedia][SQLServer JDBC
    Driver][SQLServer]Disallowed implicit conversion from data type
    datetime to data type timestamp, table 'myTbl', column 'duration'.
    Use the CONVERT function to run this query.
    I have a field named duration hh:mm:ss.lll that I am trying
    to insert into MS SQL. DB has field defined as [duration]
    [timestamp] NOT NULL,
    My insert has this: INSERT INTO myTbl( duration) VALUES(
    <cfqueryparam value="2006-05-26 11:12:13"
    cfsqltype="CF_SQL_TIMESTAMP"/> )
    Why does this not work? rrrrrrrrrrrrrr! BTW: also tried with
    seconds as 13.111 which did not work. Does the db duration need to
    be date? I just want to store a duration for the time of a movie...
    10 Q
    Duration as a timestamp? How odd, most people would store it
    as an integer. Or, if you want to build your own string, the syntax
    is {ts 'yyyy-mm-dd hh:mm:ss'}. The seconds might not be required.
    In any event, use createodbcdatetime() for the value you want
    to put into your table.

  • Problem regarding change of data type x to data type c

    Hi,
    Is there any way to change the data type x to data type c.
    w_end_record             TYPE x,
    SPLIT i_data_file AT c_delimiter INTO i_ekko-rtype
                                                i_ekko-ebeln
                                                i_ekko-bsart
                                                i_ekko-lifnr
                                                i_ekko-loekz
                                                w_end_record.
          macro_append_internal_table i_ekko.
    When I do syntax check in ECC6.0 it's showing the error "w_end_record"  must be Character type(C,N,D,T).The error is due to Unicode.
    I was using the class CL_ABAP_CHAR_UTILITIES but I am not able to find out appropriate attributes for it. Can anybody tell me the solution to resolve the problem.
    Is there any other to solve the problem.
    Thanks & Regards
    Prabhat

    Hi,
    Try following this peice of code.
    TYPES: BEGIN OF TAB_TYPE,
             TEXT(10)   TYPE C,
             XTEXT(160) TYPE X,
           END OF TAB_TYPE.
    DATA: TAB    TYPE STANDARD TABLE OF TAB_TYPE,
          WA_TAB TYPE TAB_TYPE.
      CONVERT TEXT TAB-TEXT INTO SORTABLE CODE TAB-XTEXT.
    Hope it works.
    Thanks,
    Sandeep.

  • (Again) java.util.Date vs java.sql.Date

    Hi there,
    (Again) Im trying to understand the EXACT difference between
    java.util.Date vs java.sql.Date.
    Googling, I can see that this is a very "popular" subject, but I still
    cannot figure out it exactly.
    Many writers claim that java.sql.Date only stores the DATE part (yyyy-
    mm-dd) but not the TIME part (hh:MM:ss) of a Date/Time value, but that
    I can easily disprove:
                    java.util.Date ud = new java.util.Date();                 java.sql.Date sd = new java.sql.Date(ud.getTime());                 System.out.println(DateFormatUtils.                                 format(ud, "yyyy-MM-dd HH:mm:ss.SSS"));                 System.out.println(DateFormatUtils.                                 format(sd, "yyyy-MM-dd HH:mm:ss.SSS"));
    Output:
                    2009-09-18 15:17:36.635                 2009-09-18 15:17:36.635
    So, apparently, java.sql.Date and java.util.Date have THE SAME
    precision (at least down to the millisecs...).
    And the official API documentation, really looks more confusing than
    helpful to me::
    *"java.sql.Date:*
    *A thin wrapper around a millisecond value that allows JDBC to identify*
    *this as an SQL DATE value. A milliseconds value represents the*
    *number of milliseconds that have passed since January 1, 1970*
    *00:00:00.000 GMT.*
    *To conform with the definition of SQL DATE, the millisecond values*
    *wrapped by a java.sql.Date instance must be 'normalized' by setting*
    *the hours, minutes, seconds, and milliseconds to zero in the*
    *particular time zone with which the instance is associated. "*
    Exactly what means "an SQL DATE value" ? How EXACTLY does it differ
    from a java.util.Date value?
    Most importantly: WHY does JDBC need to distinguish between them?
    And, here again: *"a java.sql.Date instance must be 'normalized' by*
    *setting the hours, minutes, seconds, and milliseconds to zero in the*
    *particular time zone..."*
    What does that mean exactly? Apparently, the constructor doesnt
    enforce this restriction, per the example above. So what's the REAL
    point with this type, java.sql.Date?
    Very greatful, if you can help me clarify this, once and for all.
    TIA,

    And the official API documentation, really looks more confusing than helpful to me:The problem is that you need to understand SQL as well as Java for this to make sense. It's not the Java API's job to tell you how your SQL database works - there's a myriad of subtle differences even when the DB is compliant with the SQL spec.
    Most compliant databases support DATE, TIME, and TIMESTAMP values. DATE represents only a date. TIME represents only a time. TIMESTAMP represents both. There are further complicating factors, but that's roughly how it stands.
    In Java the normal type for representing time is (or was when the API was created) the java.util.Date but this is a close approximation only to the TIMESTAMP value. In order to bring the two together the java.sql.Date, java.sql.Time and java.sql.Timestamp classes were created. Making them derive from java.util.Date was probably not a good idea.
    java.util.Date suffers from a number of deficiencies. java.util.Calendar was supposed to address them but didn't really succeed. The JodaTime library is rather better, but it's all a lot more complicated than you might expect - partly because time management really is a much harder problem than it appears at first glance - there are timezones, leap years, leap seconds, the difference between astronomical and atomic time, and so on and so forth.

  • ABAP Data type to XI data type mapping

    Hi,
    I am creating a message type in XI corresponding to a ABAP structure. There are couple of data types on the ABAP side (for example: RAW, QUAN, CURR CUKY, UNIT, NUMC etc) which i have no idea on what it should be mapped to on the XI side(xsd:string, xsd:token, xsd:int etc).
    Is there is any document on mapping from ABAP data type to XML data type ? if yes please send it across.([email protected])
    if no doc available, if some body could let me know what these ABAP data type would map on the XI side it would great.
    Best Regards,
    Kiran

    Hi Kiran,
    just some more background information to the data types CURR, CUKY, QUAN, UNIT:
    1) Each field of data type CURR must be assigned to a field of data type CUKY (the financial amount must be assigned to a currency) and each field of data type QUAN must be assigned to a field of data type UNIT (each quantity must have a dimension). If you want to know this assignment for your specific ABAP structure, you can find it using transaction SE11 with your ABAP structure and go to the tab <i>Currency/Quantity fields</i>. Here you find the information under <i>Reference table</i> and <i>Ref. field</i>.
    2) The default number of decimals for a field of data type CURR is 2, but this can be overwritten by the assigned CUKY field. You can check the actual number of decimals for a specific currency with transaction OY04. Here are all currency list that do <b>not</b> have 2 decimals.
    3) The default number of decimals for a field of data type QUAN is 3, but this can be overwritten by the assigned UNIT field. You can check the actual number of decimals for a specific unit with transaction CUNI. Click on <i>Units of measurement</i> (pick the correct dimension first), double click on your unit and you find the info in the field <i>Decimal places</i>.
    4) Depending on the data you receive your conversions can get quite tricky. Lets take as an example a field of type CURR. If you find the value 1000 in there, this would convert to 10.00 USD if the assigned CUKY field contains the value USD (US dollar). But the same value ca represent 1000 JPY (Japanese Yen) if the assigned CUKY field contains the value JPY. What i try to say is that the value in the field of type CURR alone does not give you the actual amount, you have to know the value of the CUKY field as well. Similar for QUAN and UNIT.
    Regards,
    Claus

  • How to change a date value from "java.util.Date" to "java.sql.Date"?

    Hi all,
    How to change a date value from "java.util.Date" to "java.sql.Date"?
    I m still confusing what's the difference between them.....
    thanks
    Regards,
    Kin

    Thanks
    but my sql statement can only accept the format (yyyy-MM-dd)
    such as "select * from xx where somedate = '2004-12-31'
    but when i show it to screen, i want to show it as dd-MM-yyyy
    I m using the following to change the jave.util.Date to str and vice versa. But it cannot shows the dd-MM-yyyy. I tried to change the format from yyyy-MM-dd to dd-MM-yyyy, it shows the wrong date in my application.
         public String date2str(java.util.Date thisdate)     {
              if (thisdate != null)     {
                   java.sql.Date thissDate = new java.sql.Date(thisdate.getTime());
                   return date2str(thissDate);
              }     else     {
                   return "";
         public String date2str(java.sql.Date thisdate)     {
              if (thisdate != null)     {
                   SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                   return sdf.format(thisdate);
              }     else     {
                   return "";
         public java.util.Date str2date(String thisdate)     {
              String dateFormat = "yyyy-MM-dd"; // = 1998-12-31
              java.util.Date returndate = null;
              if (thisdate != null)     {
                   SimpleDateFormat dateFormatter = new SimpleDateFormat(dateFormat);
                   try {
                        returndate = dateFormatter.parse(thisdate);
                   } catch (ParseException pe) {
                        System.out.println (pe.getMessage());
              return returndate;
         }

Maybe you are looking for

  • I want to keep my music on my macbook and my movies on my external hard drive how do i get itunes to recogonise my external hard drive.?

    I want to keep my music on my macbook pro and my movies on my external hard drive how do i get itunes to recogonise my external hard drive.? so i can drag more movies across later. i am able to plug my external into my Apple Express to stream to my a

  • Macbook Pro power cables

    Hi I bought I macbook pro in the summer of 2009 and then in 2010 I dropped it on the floor and this summer got a replacement. I'm pretty sure the new MBP I have has some sort of different power going to it than my old MBP - I believe the new MBP func

  • Exporting Options in Final Cut Pro

    At work I can Export a sequence out of final cut pro as a motion jpeg A or use sorensen 3. At home I have The same version of FCP but do not have those options. I'm Talking Final Cut Pro 6. I can export motion jpeg through Quicktime Pro. Any Thoughts

  • Deskjet parallel port

    I am using an old HP printer (842C Deskjet) which works fine as my LAN connected printer. I am about to replace the computer to which it's connected with one that probably does not have a parallel port to match the connector on the Deskjet. Is there

  • Safari opens, but I don't see any window

    Hi. I know there's a thread like this, but I don't have the same files that I can trash to solve the problem. Safari upgraded to v5, and since then I cannot see any window when I open it - just the menu on the upper bar. Here's the report: Process: S