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
PearlJamFanaticAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CEHJCommented:
Just format it. What format do you want. The most rational one is ISO, which you can do with
java.sql.Date d = rs.getDate("datefield");
String cell = d.toString(); //2007-02-30

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mick BarryJava DeveloperCommented:
simplest would be to use the date formatting functions provided by the database to format them in the select
Mick BarryJava DeveloperCommented:
That way you can use the result set directly, lot simpler than messing around formating them on the fly
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

PearlJamFanaticAuthor Commented:
objects: yes I want to do this in the select itself. Please give an example of the select statement that does the conversion.
Mick BarryJava DeveloperCommented:
we rarely use oracle or sybase. have a look at the links above, should be straight forward
CEHJCommented:
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)
slightwv (䄆 Netminder) Commented:
In Oracle you can convert a Date to any string imaginable with TO_CHAR and a format mask.

To convert an Oracle date to the Sybase format:
select to_char(sysdate,' YYYYMMDD')

Note that Oracle date datatypes have a time portion built in.  If you use the format above you will lose it.
slightwv (䄆 Netminder) Commented:
wilcoxonCommented:
In Sybase, you can use convert.  Specifically, to get YYYYMMDD, it is:

select convert(char(8), getdate(), 112)
-- just replace getdate() in the above with whatever date field you want.
wilcoxonCommented:
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.
awking00Information Technology SpecialistCommented:
convert(char(8),sybasedate,112) = to_char(oracledate,'yyyymmdd')
CEHJCommented:
:)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.