Hi c in my case IAm inserting date in oracle table.. i have to insert in MonthYYYY format and this is one of my key.. If i insert in this format i get the date as 1st of month and year like this 1 july 2002 and i want only july 2002 and suggestion for inserting in oracle regds
Hi thanks for answer I am using java.text b4 only but the problem is this when i insert the format monthyyyy in oracle it is inserted in format of ddmonth yyyy and as it is a key for me that to insert only once in a month . exactly i want to insert date in format monthyyyy so that i can resist to insert again in same month thanks regds
hi, Well, what you can try is , do modifications in ur SQL statements where you actually insert the record. Something like,
Insert into Table(recDate) values ( To_Date(jspDate,'MM/RRRR')); where jspDate is Date from ur jsp page. To_Date() is oracle function. This will work for oracle only. Hope this helps you out.
"A scientist is not person who gives right answers but a person who asks right questions"
Joined: Jul 25, 2001
Hi C Iam inserting date in this way only.. insert into table(tdate)values (to_date('"+S3+"','Monthyyyy')); Here S3 is a date variable java.sql It is inserting date but the format is the same default format of oracle dd-mon-yy and it inserts with the 1st date of month .. c if i insert this month it will insert 1-july-2002 and i want only july2002 any suggestion thanks
Joined: Jun 13, 2002
Hi, try making the column in the database where u storing the info as varchar2 instead of date and then try.I think it will work. Piyush
I think you need to step back from the immediate problem for a moment and ask yourself what exactly is wrong with it using the first day of the month? If your system is only concerned with the month and the year, surely it doesn't matter if the database decides to store a day with it. Have you written the code which uses or displays this stored month/year field yet? Does that code care whether there is a day stored with it, or just use/display the month and year? I think the database is just being sensible. You have asked to store a month and year in a date field, so it has defaulted the day to the first to make it a valid date. Put another way. If I hand you a one-page-per-day diary and ask you to point to "July 2002", which page do you point to?
Piyush Daiya and Frank Carver are rite, You can't store just month and year in Oracle Date column I guess,so make it a varchar2 column in database or retrive full date from the database and parse it in frontend as per u'r application.
Hi, guy, try to use rs.getString() to read the DateTime out first, then use SimpleDateFormat to convert the string to your Date format, I tested it, works very well.
Joined: Jul 25, 2001
That is okee..man U cant use varchar2() in u r application instead of Date as u cant operate on oracle date Queries.. I got solution for that man .. I am inserting right values and it is showing 1st day of month due to the oracle server default format . so what ever in what ever format i insert date it will show in its default format.. so nothing to change only change default date format of oracle.... thx guys regds