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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:27:44+00:00 2026-06-15T09:27:44+00:00

I am working on a homework problem, I’m close but need some help with

  • 0

I am working on a homework problem, I’m close but need some help with a data conversion I think. Or sysdate – start_date calculation

The question is:

Using the EX schema, write a SELECT statement that retrieves the date_id and start_date from the Date_Sample table (format below), followed by a column named Years_and_Months_Since_Start that uses an interval function to retrieve the number of years and months that have elapsed between the start_date and the sysdate. (Your values will vary based on the date you do this lab.) Display only the records with start dates having the month and day equal to Feb 28 (of any year).

DATE_ID     START_DATE                          YEARS_AND_MONTHS_SINCE_START 
2           Sunday   , February  28, 1999       13-8                         
4           Monday  , February  28, 2005        7-8                          
5           Tuesday  , February  28, 2006       6-8 

Our EX schema that refers to this question is simply a Date_Sample Table with two columns:

DATE_ID     NUMBER NOT Null

START_DATE  DATE

I Have written this code:

SELECT date_id, TO_CHAR(start_date, 'Day, MONTH DD, YYYY') AS start_date , 
  NUMTOYMINTERVAL((SYSDATE - start_date), 'YEAR') AS years_and_months_since_start
FROM  date_sample
WHERE TO_CHAR(start_date, 'MM/DD') = '02/28';

But my Years and months since start column is not working properly. It’s getting very high numbers for years and months when the date calculated is from 1999-ish. ie, it should be 13-8 and I’m getting 5027-2 so I know it’s not correct. I used NUMTOYMINTERVAL, which should be correct, but don’t think the sysdate-start_date is working. Data Type for start_date is simply date. I tried ROUND but maybe need some help to get it right.

Something is wrong with my calculation and trying to figure out how to get the correct interval there. Not sure if I have provided enough information to everyone but I will let you know if I figure it out before you do.

It’s a question from Murach’s Oracle and SQL/PL book, chapter 17 if anyone else is trying to learn that chapter. Page 559.

  • 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-15T09:27:45+00:00Added an answer on June 15, 2026 at 9:27 am

    you’ll want MONTHS_BETWEEN in that numtoyminterval as the product of subtracting two date variables gives the answer in days which isn’t usable to you and the reason its so high is you’ve told Oracle the answer was in years! Also use the fm modifier on the to_char to prevent excess whitespace.

    select date_id, 
           to_char(start_date, 'fmDay, Month DD, YYYY') as start_date,
           extract(year from numtoyminterval(months_between(trunc(sysdate), start_date), 'month') )
           || '-' ||
           extract(month from numtoyminterval(months_between(trunc(sysdate), start_date), 'month') )
           as years_and_months_since_start
      from your_table
     where to_char(start_date, 'MM/DD') = '02/28';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on homework and I'm close but I am having an issue. I
I am working on some homework here, but I have completely run out of
I'm working on a homework problem and I'm having some difficulties creating a O(n*logn)
I am working on a school homework problem. I need to create 2 int[]
I have a homework problem here I've been working on; here is the description:
I'm working on some homework for an intro to C class, in which we
I'm working on a homework problem out of Stalling's Operating Systems: Internals and Design
So I am working on some homework and I have to complete a size
I'm working on a problem where I need to create a CartesianProduct class. I
I am working on a problem for homework in a Java Programming course, and

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.