Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar Mark Forums Read
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 02-03-2013, 10:47 PM   #1
Socks
Confirmed User
 
Industry Role:
Join Date: May 2002
Location: Toronto
Posts: 8,475
I need some quick SQL help

In one table named AD I have a date_of_birth field, saved like 1970/01/30
In another table named AQ I have quote_date saved like 2009/01/30

I want to create a new column in AD called "age" and save how old they were when they got the quote.

So on January 30th, 2009, they were 39 years old. I want to save "39" to a new field in the same row as date_of_birth.

Important note: Both fields are strings, not date fields. :/

Oracle, but most SQL statements work.. Also doesn't need to be to-the-day accurate.

How do I do this?

Last edited by Socks; 02-03-2013 at 10:49 PM..
Socks is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-04-2013, 07:43 AM   #2
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,073
What you want is the same as the DateDiff() function in sql server but Oracle does not have a DateDiff function.

Here is a solution I found for getting days, hours, minutes: http://asktom.oracle.com/pls/asktom/...42712657900129

I would usually use a DateDiff() that returned months and then divide them by 12 to get the age. Not sure of the best way to do that in Oracle.

As far as the dates being strings you should be able to cast them as dates.

Hope that helps.

.
__________________
All cookies cleared!

Last edited by sarettah; 02-04-2013 at 07:46 AM..
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-04-2013, 08:13 AM   #3
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,073
Here is a beter solution http://stackoverflow.com/questions/3...irth-and-today

.
__________________
All cookies cleared!
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks
Thread Tools



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.