Home » SQL & PL/SQL » SQL & PL/SQL » People who will reach legal age after one month
People who will reach legal age after one month [message #567842] Sun, 07 October 2012 01:56 Go to next message
avrillavinge
Messages: 98
Registered: July 2007
Member
I have a classification based on age and nationality to calculate if the people will reach legal age after one month .

I have the peoples age , the legal age of people is 18 years .

I need to know how many people will reach this age after 1 month.

can you pls guide
Re: People who will reach legal age after one month [message #567846 is a reply to message #567842] Sun, 07 October 2012 02:31 Go to previous messageGo to next message
John Watson
Messages: 4516
Registered: January 2010
Location: Global Village
Senior Member
If the task is simply to identify people who have a birthday any day in the next month, then you could use the ADD_MONTHS and EXTRACT functions. If the algorithm has to be precise, you will need to develop something based on the number of days (28, 29, 30, or 31?) in the current or following month.
Re: People who will reach legal age after one month [message #567847 is a reply to message #567846] Sun, 07 October 2012 02:37 Go to previous messageGo to next message
avrillavinge
Messages: 98
Registered: July 2007
Member
Basically the requirement is to calculate the no of days between his age and the legal age which is 18 years...

If the will be 18 years in a month then i need to flag him...i need only these guys who will reach 18 after a month .
Re: People who will reach legal age after one month [message #567848 is a reply to message #567847] Sun, 07 October 2012 02:41 Go to previous messageGo to next message
John Watson
Messages: 4516
Registered: January 2010
Location: Global Village
Senior Member
So if the date now were 30 September, and the person's birthday is 31 October, should he be reported?
--
edit: ie, is the list of reported people constant throughout the month? Or does it vary as the month progresses?

[Updated on: Sun, 07 October 2012 02:44]

Report message to a moderator

Re: People who will reach legal age after one month [message #567849 is a reply to message #567848] Sun, 07 October 2012 02:55 Go to previous messageGo to next message
avrillavinge
Messages: 98
Registered: July 2007
Member
yes sir , you are right
basically the days between his legal age ie 18 years and his current age should have a differnce of 30 days .

If he will reach 18 years after 30 days he should be reported

It will be daily basis so the number will change everyday
Re: People who will reach legal age after one month [message #567850 is a reply to message #567849] Sun, 07 October 2012 03:13 Go to previous messageGo to next message
Michel Cadot
Messages: 58938
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
With any SQL question, Post a working Test case: create table and insert statements along with the result you want with these data then we will be able work with your table and data. Explain with words and sentences the rules that lead to this result.

Before, Please read OraFAQ Forum Guide and How to use [code] tags and make your code easier to read.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code, use code tags and align the columns in result.
Use the "Preview Message" button to verify.
Also always post your Oracle version, with 4 decimals.

Regards
Michel
Re: People who will reach legal age after one month [message #567851 is a reply to message #567849] Sun, 07 October 2012 03:21 Go to previous message
John Watson
Messages: 4516
Registered: January 2010
Location: Global Village
Senior Member
So the algorithm is NOT based on month, but on a fixed 30 day period. So subtract the birthday from the current date, and compare the result with 30.
If you can't do this, provide the test case and an example of what you have tried so far.
Previous Topic: calc sanctions to employee
Next Topic: General SQL
Goto Forum:
  


Current Time: Sun Aug 31 03:29:51 CDT 2014

Total time taken to generate the page: 0.13310 seconds