Select records based on Timestamp

Hi

This is rather simple question, i might doing something wrong. I have a table with one of the column as timestamp.
The data stored is in format MM/DD/YYYY 24HH:MI:SS.
I want to select the records greater or equal to a certain date.
When i try select * from <tablename> where to_char(timestamp,'MM\DD\YYYY') >= '04/12/2006 5:41:43 PM'
it is returning all the records even before the date given in where condition.

Thanks
KOTTUSRIAsked:
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.

ram_0218Commented:
no. For doing the date or timestamp comparison you got to use to_date, if you use to_char, its gonna do a alphabetic sort not a date sort thus you wont get proper records as you expect. Try this.

select * from <tablename> where to_date(timestamp,'MM\DD\YYYY') >= to_date('04/12/2006 17:41:43','mm/dd/yyyy hh24:mi:ss')
/

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
KOTTUSRIAuthor Commented:
Its says "ORA-01843: not a valid month"
0
ram_0218Commented:
Try now.

if timestamp is a date or timestamp field, then directly do this.
select * from <tablename> where timestamp >= to_date('04/12/2006 17:41:43','mm/dd/yyyy hh24:mi:ss')

if timestamp  is a varchar2 field, do this.
select * from <tablename> where to_date(to_char(timestamp,'mm/dd/yyyy hh24:mi:ss'),'mm/dd/yyyy hh24:mi:ss') >= to_date('04/12/2006 17:41:43','mm/dd/yyyy hh24:mi:ss')

0
KOTTUSRIAuthor Commented:
I got the output when i do select * from <tablename> where timestamp >= to_date('04/12/2006 17:41:43','mm/dd/yyyy hh24:mi:ss')

Thanks
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.