If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > if date_made > or = to birth_date +30

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-30-06, 14:38
domini domini is offline
Registered User
 
Join Date: Jun 2005
Posts: 27
Unhappy 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!
Reply With Quote
  #2 (permalink)  
Old 01-30-06, 14:43
Teddy Teddy is offline
Purveyor of Discontent
 
Join Date: Mar 2003
Location: The Bottom of The Barrel
Posts: 6,075
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? ***
Reply With Quote
  #3 (permalink)  
Old 01-30-06, 16:30
domini domini is offline
Registered User
 
Join Date: Jun 2005
Posts: 27
Hey,

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.
Reply With Quote
  #4 (permalink)  
Old 01-31-06, 03:42
Littlefoot Littlefoot is offline
Lost Boy
 
Join Date: Jan 2004
Location: Croatia, Europe
Posts: 3,629
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 03:49.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On