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 8498511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:25:24+00:00 2026-06-11T00:25:24+00:00

I have below information in table and want to retrive the count if difference

  • 0

I have below information in table and want to retrive the count if difference between two dates is >= 1.

Id  testdate  exdate    
1   20120502  20120501  --> This should included, because diff is 1    
2   20120601  20120601  --> This should not included, because diff is 0    
3   20120704  20120703  --> This should included, because diff is 1    
4   20120803  20120802  --> This should included, because diff is 1

Based on the above data, my select count should return 3.

I am trying the following, but it’s not giving any results:

select count(to_char(testdate,'YYYYMMDD')-to_char(exdate,'YYYYMMDD')) from test ;
  • 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-06-11T00:25:25+00:00Added an answer on June 11, 2026 at 12:25 am
    select count(*)
      from my_table
     where testdate <> exdate 
    

    You really should convert those to a date data-type though… it saves a lot of problems in the long run.

    Your query will give you results. It will return 4. It gives you results because as long as the result of testdate - exdate is not null it will return a value for that row.

    However, as you’re not using dates Oracle will most probably convert those to numbers, which won’t help for date comparisons should you do that in the future.

    20120901 - 20120831 = 70 -- not 1
    

    Okay, from your comment:

    Working with ,if i use down voteaccept select count(*) from test where
    to_char((testdate,’YYYYMMDD’) – to_char(exdate,’YYYYMMDD’)) >= 1; .But
    count is one of the column.how to retrive above select statement as
    one of the column

    you’re trying something completely different.

    Your dates are actually dates; it’s helpful to post this. You’re looking for an analytic function, specifically count().

    select a.*, count(*) over ( partition by 1 ) as ct
      from my_table a
     where trunc(exdate) <> trunc(testdate)
    

    Note the trunc function, which, without additional parameters will remove the time portion of the date this enabling a direct comparison without resorting to converting the date to a character.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two table (below codes) , want to retrieve last row of trackers_data
I have such table (below). I want to get someone's detail information if someones
I have a div that I want to appear directly below a table cell
I have the below method which is meant to append information to a file
i have the following code: <h3> Your Profile </h3> The information below is what
I have an XML document containing contact information as seen below: <contact type=individual> <firstname>Some</firstname>
I have the following database table with information about people, diseases, and drugs: PERSON_T
I have a table like this below. And there is a div container with
I have a database table that stores document information (DocID, Name, Type, Owner, etc).
I have this page table structure to store all the website page information, page_id

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.