Link to home
Start Free TrialLog in
Avatar of PearlJamFanatic
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(string2) must return true
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of PearlJamFanatic
PearlJamFanatic

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)
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
:)