PearlJamFanatic
asked on
Date format conversion
In Sybase 20070208
In Oracle 08/02/2007 00:00
What query can i use to make them equal strings. I am dumping this data/table into CSV. So the conversion must happen in select statement itself. After conversion they must be string1.equalsIgnoreCase(s tring2) must return true
In Oracle 08/02/2007 00:00
What query can i use to make them equal strings. I am dumping this data/table into CSV. So the conversion must happen in select statement itself. After conversion they must be string1.equalsIgnoreCase(s
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
simplest would be to use the date formatting functions provided by the database to format them in the select
That way you can use the result set directly, lot simpler than messing around formating them on the fly
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
objects: yes I want to do this in the select itself. Please give an example of the select statement that does the conversion.
we rarely use oracle or sybase. have a look at the links above, should be straight forward
Bear in mind that using the db will make your code unportable. You could do it all in Java
http://opencsv.sourceforge.net/apidocs/au/com/bytecode/opencsv/CSVWriter.html#writeAll(java.sql.ResultSet, boolean)
http://opencsv.sourceforge.net/apidocs/au/com/bytecode/opencsv/CSVWriter.html#writeAll(java.sql.ResultSet, boolean)
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Guess I should have added the link:
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/sql_elements004.htm#i34924
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/sql_elements004.htm#i34924
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Oops. I read that backwards. Your Sybase date is already in YYYYMMDD format. To convert a Sybase date to DD/MM/YYYY H24:mm, you can do:
select convert(char(10), getdate(), 101)+' '+convert(char(5), getdate(), 108)
There is no exact format that matches what Oracle gives so I just constructed one from two converts.
select convert(char(10), getdate(), 101)+' '+convert(char(5), getdate(), 108)
There is no exact format that matches what Oracle gives so I just constructed one from two converts.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
:)