How to insert current date into dataBase(SQL)


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: How to insert current date into dataBase(SQL)

Hybrid View

  1. #1
    Join Date
    Dec 2007
    Posts
    2

    How to insert current date into dataBase(SQL)

    In my JSP I am sending the current date as follows

    <% java.text.DateFormat dateFormat = new java.text.SimpleDateFormat("yyyy-MM-dd");
    String schduleDate = dateFormat.format(new java.util.Date());
    %>

    <input type="text" name="scheduledDate" value="<%=dateFormat.format(new java.util.Date()) %>" readonly="true"/>

    But in the DataBase (SQL) it is inserting 1/1/1900.
    please help

  2. #2
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    Welcome To DevX

    To get the current date, do
    Code:
    import java.util.Date;
        import java.text.DateFormat;
        import java.text.SimpleDateFormat;
    
        private String getDateTime() {
            DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
            Date date = new Date();
            return dateFormat.format(date);
        }
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

Similar Threads

  1. Replies: 4
    Last Post: 01-06-2007, 12:50 AM
  2. Replies: 4
    Last Post: 07-30-2006, 11:50 PM
  3. how to clone database using mysql
    By zarien in forum Database
    Replies: 1
    Last Post: 05-17-2006, 04:27 AM
  4. Replies: 0
    Last Post: 04-15-2002, 05:31 AM
  5. SQL Tutorial (Answer Q's & post your reply)
    By bigbastard4 in forum Database
    Replies: 2
    Last Post: 05-16-2001, 07:24 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center