Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2005

    Unhappy Unanswered: if date_made > or = to birth_date +30

    I have a question...I have two tables, one with an ID number and year_made in it, and another one with a birth_date and death_date.

    I'm trying to bring back ID numbers where the artist was 30 years of age or younger when the item was made. It requires a calulation to figure out the birth date + 30 years, and to return any id numbers where date_made falls into one of those 30 years between the birth_date and birth_date + 30.

    However, I've not the foggiest on how to set it up in SQL. Or rather, I have too much fog, and not enough clear vision.

    Can someone help me?

    Thanks ahead of time!

  2. #2
    Join Date
    Mar 2003
    The Bottom of The Barrel
    Provided Answers: 1
    There's datediff() in TSQL and JETSQL, not sure about the PL/SQL equivilent..
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  3. #3
    Join Date
    Jun 2005

    Thanks, that got me on the right track--until I realized the date fields in question were not true dates, because some are entered as "circa 1900" and the like. Gah.

    Thank you again.

  4. #4
    Join Date
    Jan 2004
    Croatia, Europe
    Provided Answers: 5
    Bad database design ... why is a date column created using the character datatype?

    Teddy, why did you mention PL/SQL? Is it Oracle's Procedural Languange extension to SQL? If so, would it be more precise to talk about Oracle SQL (rather than PL/SQL) equivalent function?

    And, if it was about Oracle, you could use ADD_MONTHS function (by multiplying 30 (years) with 12 (months)); something like

    WHERE date_made <= ADD_MONTHS(birth_date, 30 * 12)

    (If the artist was 30 years of age or younger, wouldn't you rather need <= instead of >= as you suggested in the thread subject?)
    Last edited by Littlefoot; 01-31-06 at 04:49.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts