Convert from String to Date for storing in SQL Server 2000

Hi,
I've accepted some values from a user using a form in HTML.Now using Servlets I transfer the value to my java code .
I want to know how can I convert a DATE accepted from the user thats presently in "String" format to the "datetime" format for SQL Server2000.
Please guide me with some steps and I shall be grateful.
Thanks

The java.text.SImpleDateFormat class is most probably of use.
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
String enteredDate = "25/12/2006";
java.util.Date utilDate = sdf.parse(enteredDate);
java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());You can then use the java.sql.Date with the "setDate()" method of a prepared statement. This method would be database independant, as you are setting an actual date, not depending on a specific format on the database end.

Similar Messages

  • Does xcelsius access data model in MS sql server 2000

    have the following scenario: I need to create a dashboard which will be accessed through a Microsoft Office SharePoint server portal. This dashboard will be used for analysis of Agencies and Underwriters; they should be able to drill down to policy level details. 
    The data will originate from a Data Warehouse (Relational Schema) which resides on a Microsoft SQL server 2000 platform.
    Q) Does Xcelsius work off a relational model or does the data model need to be converted to a Dimensional Star schema?  Do you have to create Cubes?
    A)
    Q) It was mentioned in the book that Xcelsius can connect to a Microsoft SharePoint server using web part, however there is no information in the help menu to do that task? 
    A)
    My thought) I was also thinking that the data model build on MS SQL SERVER 2000 can be used to create a Universe, which then can link to Live Office using Query as a Web Service (QAAWS) and used to build Xcelsius model.  (Does one have to go this route, or can one access the data model created on SQL SERVER 2000?)
    Any Feedback)

    I need to create a dashboard which will be accessed through a Microsoft Office SharePoint server portal. This dashboard will be used for analysis of Agencies and Underwriters; they should be able to drill down to policy level details.
    The data will originate from a Data Warehouse (Relational Schema) which resides on a Microsoft SQL server 2000 platform.
    Q) Does Xcelsius work off a relational model or does the data model need to be converted to a Dimensional Star schema? Do you have to create Cubes?
    A) Xcelsius works on an X/Y (Column/Row) table model, strictly based on the Excel structure.  Though the underlying data model is a table, it is not inherently relational as it does not impose any BC Normal Form requirements.
    Xcelsius works primarily with data embedded in an integrated Excel workbook.  Data can be input to the workbook by a variety of methods, from importing a premade Excel workbook into the the model to retrieving data from flat files (.txt, .xml, .etc) to getting data from a connection such as a WebService. 
    There is no capability to connect directly, 1:1, to a database source and execute SQL queries.  An intermediary is required to retrieve data from a database, such as a WebService or an XML Data connection.

  • Convert from String to Date

    Hello,
    I have the following string: "Thu Apr 22 00:00:00 IDT 2004"
    and I need to convert it to Date object.
    I tried to use Date.parse() and Date.valueOf(),
    but then I get the IllegalArgumentException.
    How can I do this?
    Thanks.

    split ur string. get year,month,day in int
    time in long
    now it will work for u
         Date d = new Date(int year,int mon,int date);//Deprecated
         d.setTime(long time); //Sets this Date object to represent a point in time that is time milliseconds after January 1, 1970 00:00:00 GMT.
         System.out.println(d);
    Ignore that answer, please and DynaFest read the API!

  • Conversion of string to data(Flat file to sql server) Transformations

    Hi All,
    I have a requirement in which I am trying to convert a field of type string which contains date from source file to field of type datetime in sqlserver by using all the below expressions
    to_date(DATE, 'yyyy/mm/dd-hh24:mi:ss' )
    to_date(DATE, 'yyyy/mm/dd' )
    However it is not throwing any errors but the data of the date field is being loaded with null values(Date is present in flat file).
    Any inputs plz???
    Thanks
    U

    Can you post a sample of the date string you are trying to convert?

  • Convert from String data type to Character data type

    Hi...,
    I'm a beginner. I try to make a program. But I don't know how to convert from string to data type. I try to make a calculator with GUI window. And when somebody put "+" to one of the window, I just want to convert it to Character instead of String.
    Sorry of my bad english..
    Please help me....
    Thanks

    String s = "a+b";
    char theplus = s.charAt(1);

  • How to retrieve Min(startDate) and Max(endDate) for different groups of data? (sql server 2000)

    My sample dataset (below) contains 3 groups -- 'a', 'b', 'c'.  I need to retrieve the Min(startDate) and Max(EndDate) for each group so that the output looks something like this (date format not an issue):
    fk   minStart       maxEnd
    a    1/13/1985    12/31/2003
    b    2/14/1986    12/31/2003
    c    4/26/1987    12/31/2002
    What is the Tsql to perform this type of operation?  Note:  the actual data resides in a sql server 2000 DB.  If the Tsql is different between version 2000 and the later versions -- I would be grateful for both versions of the Tsql
    --I noticed that multiple lines of Insert values doesn't work in Sql Server 2000 -- this sample is in Sql Server 2008
    create table #tmp2(rowID int Identity(1,1), fk varchar(1), startDate datetime, endDate datetime)
    insert into #tmp2
    values
    ('a', '1/13/1985', '12/31/1999'),
    ('a', '3/17/1992', '12/31/1997'),
    ('a', '4/21/1987', '12/31/2003'),
    ('b', '2/14/1986', '12/31/2003'),
    ('b', '5/30/1993', '12/31/2001'),
    ('b', '6/15/1994', '12/31/2003'),
    ('b', '7/7/2001', '12/31/2003'),
    ('c', '4/26/1987', '12/31/1991'),
    ('c', '8/14/1992', '12/31/1998'),
    ('c', '9/10/1995', '12/31/2002'),
    ('c', '10/9/1996', '12/31/2000')
    Thanks
    Rich P

    Rich
    It is unclear what you are trying to achieve, you said that it is SQL Server 2000 but provide a sample data with SQL Server 2008 syntax
    Is it possible to use UNION ALL for your queries to make its one 
    select * from
    select * from #tmp2 t1 where exists
    (select * from (select top 1 * from #tmp2 t2 where t2.fk = t1.fk order by t2.startdate) x where x.rowID = t1.rowID)
    UNION ALL
    select * from #tmp2 t1 where exists
    (select * from (select top 1 * from #tmp2 t2 where t2.fk = t1.fk order by t2.Enddate desc) x where x.rowID = t1.rowID)
     as  der order by fk
    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

  • Invalid session : connecting from developer 6i to sql server 2000

    Hi ,
    I am facing the following problem for connecting to sql server
    2000 from oracle forms 6i.
    Oracle developer 6i(form builder 6.0.8.11.3)
    sql server 2000
    o/s windows 2000 server
    plus80.exe <username>/<password>@odbc:<dsn_name>
    SQL*Plus: Release 8.0.6.0.0 - Production on Tue Oct 24 17:36:56
    2000
    (c) Copyright 1999 Oracle Corporation. All rights reserved.
    ORA-00022: invalid session id; access denied
    ORA-00022: invalid session id; access denied
    ORA-00022: invalid session id; access denied
    Error accessing PRODUCT_USER_PROFILE
    Warning: Product user profile information not loaded!
    You may need to run PUPBLD.SQL as SYSTEM
    Server not available or version too low for this feature
    ORA-00022: invalid session id; access denied
    Connected to:
    Oracle Open Client Adapter for ODBC 6.0.5.29.0
    Microsoft SQL Server 08.00.0194
    SQL>
    pls help
    Thanks in advance
    Yogesh

    Hello ,
    this forum must have a attachment option , so it very easy for others to update their development
    Now how can i paste the procedure it have 6 - 8 pages and when i paste it, the words merge or join with others word, it become very difficult to read,,
    anyhow
    mail me i send the document
    [email protected]

  • 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);

  • Convert from String to HashMap

    Hi
    Can any body pls tell us how to convert from String to HashMap
    I have one string str="Col1=200, Col2=225";
    So how can i convert that string varibale into HashMap?

    Hi
    Can any body pls tell us how to convert from String
    to HashMap
    I have one string str="Col1=200, Col2=225";
    So how can i convert that string varibale into
    HashMap?
    Map map = new HashMap();
    String[] parts = str.split(", ");
    for (int i = 0; i < parts.length; ++i) {
        String[] entry = parts.split("=");
    map.put(entry[0], entry[1]);

  • Convert from String to boolean ??

    hi everyone..
    is there any way to convert from String (as a class) to boolean (as a primitive type) ?
    thunx

    I used : Boolean.valueOf(s).booleanValue(); ,I got the same error.What same error? Surely not this one:
    cannot resolve simple in parseBoolean method??
    equals is OK, but I think it is not convert method,
    the prev. solutions by equals don't convert the value of s (String).Yes it does, for any reasonable definition of "converts". In fact, that is essentially how parseBoolean() is implemented. From the JDK 5.0 source code, class java.lang.Boolean:
         return ((name != null) && name.equalsIgnoreCase("true"));

  • Convert from String to float

    How do I convert from String to float?

    Hi,
    you can use a Double for example - assuming value is that string to parse
    float f;
    try { Double d = new Double(value); f = d.floatValue(); }
    catch (NumberFormatException e) { f = 0.0; } // error - string value could not be parsed
    // here use your float fHope, that helps
    greetings Marsian
    P.S.: the Double class is usefull for that, because you also can get intValue(), doubleValue() or longValue() out of it for example. The StreamTokenizer for example parses numbers also only to double.

  • How to convert a string to date and then compare it with todays date???

    Hello.
    I want to set a format first for my dates
    DateFormate df = new SimpleDateFormate("yyyy-mm-dd");
    once this is done then I want to convert any string to date object in the above formate
    String str="2001-07-19";
    Date d = null;
    try{
    d = df.parse(s);
    }catch(ParseException pe) {
    pe.printStackTrace();
    First of all there is something wrong above,cus what I get for this is
    Fri Jan 19 00:07:00 MST 2001
    where as it should have been
    2001-07-19... to my understanding.
    once this part is done I need to get current date in the above set format and compare the
    current date and the date I set.
    I will appreciate the help.
    Thanks

    for the output part:
    a date is a point in time
    the output depends on the format you specify for output
    using for example a SimpleDateFormat.
    You only specified the format for parsing (which is independent for that of output) so java uses some default format ... see the DateFormat.format() method for details.
    for the comparison stuff, I just posted a little code snippet in this forum a few minutes ago.
    the hint is: Date.getTime() returns milliseconds after a fixed date
    hth Spieler

  • How can I convert from Modbus raw data to engineering units using a formula?

    Within Lookout, I have several Modbus numerical input types that do not have a linear corespondence to the Engineering values they represent.  How can I display these values accurately using a formula to convert from the raw data to an engineering value?

    I don't quite understand your reply.  I'm using Lookout 6.0.2, logged in as Administrator, in Edit Mode.  The Modbus object is named RTU06_SAV.  The Active member is 30002 with an alias of SAVfmSMT_RSL.
    Following your instructions, I opened Object Explorer and right-clicked on RTU06_SAV. 
    This opened a menu containing:  Refresh, Cut, Copy, Rename, Delete, Edit connections..., Edit Data Member Configuration, Configure Network Security and Properties.
    I assumed that I should select Edit Data Member Configuration, but maybe I'm wrong. 
    Within Data Member Configuration I can set up Linear Scaling between Raw data and Engineering data.  I know how to do that, but what I need to know is how to convert Raw data to Engineering data using a formula representing a non-linear transformation (such as a converion to a logarithmic value or perhaps a formula derived by fitting the formula to a curve on a calibration chart).
    Once I have this my Engineering data can be represented on a control panel as both a numeric value AND as a correctly reading Gauge.  It can also be properly represented on a HyperTrend graph.
    What do you suggest?

  • Convert from String to Int

    Hi,
    I have a question.
    How do I convert from String to Integer?
    Here is my code:
    try{
    String s="000111010101001101101010";
    int q=Integer.parseInt(s);
    answerStr = String.valueOf(q);
    catch (NumberFormatException e)
    answerStr="Error";
    but, everytime when i run the code, i always get the ERROR.
    is the value that i got, cannot be converted to int?
    i've done the same thing in c, and its working fine.
    thanks..

    6kyAngel wrote:
    actually it convert the string value into decimal value.In fact what it does is convert the (binary) string into an integer value. It's the String representation of integer quantities that have a base (two, ten, hex etc): the quantities themselves don't have a base.
    To take an integer quantity (in the form of an int) and convert it to a binary String, use the handy toString() method in the Integer class - like your other conversion, use the one that takes a radix argument.

  • Convert from String to Long

    Hello Frineds I want to convert from String to Long.
    My String is like str="600 700 250 300" and I want to convert it to long and
    get the total value in to the long variable.like the total of str in long varible should be 1850.
    Thank You
    Nilesh Vasani

    Maybe this would work?
    StringTokenizer st = new StringTokenizer(yourString, " ");
    long l = 0;
    while(st.hasMoreTokens()) {
        l += Long.parseLong(st.nextToken()).longValue();
    }

Maybe you are looking for

  • Problem with remove task from schedule in PWA

    In our environment problem with remove task from schedule by PWA. Problem is only when I want to remove few task in the same time, but the operation one by one is correct. In my opinion problem is with calculation schedule after remove tasks, column

  • SAP Query: InfoSet Filter

    Hey experts, I have an Infoset that contains the JEST table (status of object) and TJ02T (text of the status). In my query result I only want records in 1 language. I know I can make a selection criteria on language with a default value. But now I wa

  • Mapping Adapter Variables form: OIM 11g

    I have created a Rule Generator adaptor. Which Form should I attach this adapter to if I want it to process the Xellerate users? I tried using the Users form, the Users.User Defined Tasks, Data Object Manager form and a few others. I don't see the op

  • Disc4i Plus & Viewer v.4.1.37 EUL compatibility

    I have downloaded oracle9iAS Discoverer plus and viewer version 4.1.37. The release notes says that this version will only connect to an EUL that is created or upgraded using Discoverer Administration edition 4.1.36 or 4.1.37. My questions are: 1)Wil

  • How to use knowledge base keywords"?

    I have found links to the the knowledge base document "how to use knowledge base keywords" online but all the links lead to a dead end. The document number is 75178, and explains the use of prefixes in the knowledge base keyword search. Has anyone an