Reputation: 39
I have to insert date dynamically to database, how should I get the text value and update it ? I have tried the following code.
<input type="Text" name="tbox" id="${up.adId}" maxlength="15"size="18" value="${expiryDate}"><a href="javascript:NewCal(${up.adId},'mmddyyyy',false,24)">
UPDATE classifiedads SET expiry_date='"+ textBox[i]+"' where
in where what condition should be checked from the above code.
i want to save edited values in textbox to the database remaining untouched but as i am giving value of each textbox as expiry date initially , i am unable to write where condition for edited values please help me i am strucked .
if i update with out where condition null values are updated
thanks in advance.
Upvotes: 0
Views: 1917
Reputation: 99
You can solve this problem by changing the query with to_date(<value-to-insert>,'<format>')
Ex: select to_date('2007-01-01 12:00:01 AM','yyyy-mm-dd hh:mi:ss pm') as dt from dual;
in your case :
UPDATE classifiedads SET expiry_date=to_date('"+ textBox[i]+"','mmddyyyy') where " e.t.c
Let me know in case of any issues.
Upvotes: 0
Reputation: 240860
On servlet you would receive date in the form of String
, you need to do following steps to get Date from this string date
SimpleDateFormat
Upvotes: 1