Hi... I have a string in the format "dd.mm.yyyy hh:mm".. i need to convert it into oracle date format 'dd-mon-yy'..... How do i make it happen???
+1
A:
It's not clear where the string is, considering the java tag... Assuming a column value:
SELECT TO_CHAR(TO_DATE(t.column, 'DD.MM.YYYY HH24:MI'), 'DD-MON-YYYY')
FROM YOUR_TABLE t
OMG Ponies
2010-09-30 04:59:03
A:
If you want to perform an sql query against your database via prepared statment you can use
java.sql.Date
which stores the Date. Note that this object does not store time, just month, day and year. Also see
java.sql.Time
java.sql.Timestamp
If you are looking to format the date for display purpose, try
java.text.DateFormat
Sean
2010-09-30 05:25:47
I wish to select particular records based on some date. This date is coming in the form of String from the GUI. So i need to convert to string into oracle date.
apoorvabade
2010-09-30 05:50:46
+1
A:
How is the string sent to oracle?? Use the to_date() function to convert the java string to oracle date. http://www.techonthenet.com/oracle/functions/to_date.php
D0cNet
2010-09-30 05:28:51
Actually i wish to send the string to a web service which in turn access the database. So i wanted to convert it to the oracle date in java.
apoorvabade
2010-09-30 05:49:43
Yeah well you can always pass it as string formatted however, then in oracle just use the to_date(<string>,<same format>) and convert it using the same format.
D0cNet
2010-09-30 06:22:57