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

0

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
objectsCommented:
simplest would be to use the date formatting functions provided by the database to format them in the select
0
objectsCommented:
That way you can use the result set directly, lot simpler than messing around formating them on the fly
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy 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.
0
objectsCommented:
we rarely use oracle or sybase. have a look at the links above, should be straight forward
0
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)
0
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.
0
slightwv (䄆 Netminder) Commented:
0
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.
0
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.
0
awking00Commented:
convert(char(8),sybasedate,112) = to_char(oracledate,'yyyymmdd')
0
CEHJCommented:
:)
0
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.