Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6757723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:41:19+00:00 2026-05-26T13:41:19+00:00

Ok, so I want to convert a date value to properly format my date

  • 0

Ok, so I want to convert a date value to properly format my date for comparison, however, will converting my “DATE” data type to char affect indexing when comparing on that field? Can I resolve this by doing to_date(tochar())? Any advice on this would be greatly appreciated Thanks!

EDIT – Sorry for the lack of specifics…. basically I need to eliminate the time stamp from my date, I used the following and it appears to work TO_DATE(TO_CHAR, ‘YYYY-MM-DD’),’YYYY-MM-DD’), mind you I don’t know if this is good practice or not, but at least (or so I think) now it’s comparing a DATE against a DATE, and not a string.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T13:41:20+00:00Added an answer on May 26, 2026 at 1:41 pm

    If you are doing a comparison, you should not be converting the date to a string. You should be comparing to another date. Otherwise, Oracle won’t be able to use a non function-based index on the date column.

    In general, that is, you’re much better off coding

    WHERE some_indexed_date_column = to_date( :string_bind_variable, 
                                              <<format mask>> )
    

    rather than

    WHERE to_char( some_indexed_date_column, 
                   <<format mask>> ) = :string_bind_variable
    

    Of course, if your bind variable can be a DATE rather than a VARCHAR2, that’s even better because then you don’t have to do any data type conversion and the optimizer has a much easier time of estimating cardinalities.

    If you are trying to do some manipulation of the date– for example, if you want to compare the day portion while omitting the time portion of the date– you may want to use function-based indexes. For example, if you wanted to find all the rows that were created some time today

    WHERE trunc( some_date_column ) = date '2011-11-04'
    

    you could either create a function-based index on the date column

    CREATE INDEX idx_trunc_dt
        ON table_name( trunc( some_date_column ) )
    

    or you could rewrite the query to do something like

    WHERE some_date_column >= date '2011-11-04'
      AND some_date_column <  date '2011-11-05'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Date format: 2009-08-10T16:03:03Z that I want to convert to: @MMM dd,
I am having a date format 16-11-2011. but I want to convert it into
I want convert string value into date in my project because I am fetching
Possible Duplicate: How do I calculate relative time? I want to convert Date Value
I want to convert a user-provided date to a value of seconds since 1970.
I want to convert a varchar value that iI set up to a date
I want to convert this date ( 02-12-2010) mm-dd-yyyy to time format ie to
I am trying to convert a string into date time format. DateTime.Parse(tempfrmBankDetails.dgvBankDetails.SelectedRows[0].Cells[PaymentDate].Value.ToString(),null); This is
I have made a function to convert a textbox value to date. I want
I have strings like 84, 03 etc. that I want to convert to Date

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.