• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to Inserting current Date to DataBase

 
prasant sahoo
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64715
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The code you have shown is merely the code that displays the date in an input box. What does it look like on the screen? The way you expect?

Without further details regarding how that date -- remember that when it submitted it will just be a String value -- is being inserted into the database, I'm not sure anyone is going to be able to help you.
[ January 16, 2008: Message edited by: Bear Bibeault ]
 
Qussay Najjar
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the database you're using,
If it was Oracle I have a way for you..
 
Paul Campbell
Ranch Hand
Posts: 338
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
DB2

current date

Oracle

sysdate

mysql

CURDATE()
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic