Age of a person

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
boppanakrishna
Participant
Posts: 106
Joined: Thu Jul 27, 2006 10:05 pm
Location: Mumbai

Age of a person

Post by boppanakrishna »

hi all,
how to calculate the "Age of a person" or "difference b/w dates" using the datastage functions

ThanksinAdvance
Boppana Krishna
ajith
Participant
Posts: 86
Joined: Thu Nov 10, 2005 11:10 pm

Re: Age of a person

Post by ajith »

boppanakrishna wrote:hi all,
how to calculate the "Age of a person" or "difference b/w dates" using the datastage functions

ThanksinAdvance
Boppana Krishna
Difference between dates can be found by converting the dates to Julianday and finding out the difference between them. But then finding out the age in years,months etc, will depend upon your business rules.
suresh.narasimha
Premium Member
Premium Member
Posts: 81
Joined: Mon Nov 21, 2005 4:17 am
Location: Sydney, Australia
Contact:

Age Of a Person

Post by suresh.narasimha »

Hi,

Did you try that by using Oconv((Iconv(Date1,"DMY")-Iconv(Date2,"DMY")),"DMY") ??

Regards,
Suresh N
SURESH NARASIMHA
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Suresh - He might have, but the PX compiler would have balked at that, even if the red highlighting in the transform stage wouldn't have given it away :) [but in Server that would have worked just fine!]
Nageshsunkoji
Participant
Posts: 222
Joined: Tue Aug 30, 2005 2:07 am
Location: pune
Contact:

Re: Age of a person

Post by Nageshsunkoji »

ajith wrote:
boppanakrishna wrote:hi all,
how to calculate the "Age of a person" or "difference b/w dates" using the datastage functions

ThanksinAdvance
Boppana Krishna
Difference between dates can be found by converting the dates to Julianday and finding out the difference between them. But then finding out the age in years,months etc, will depend upon your business rules.
Thats true. We can acheive the difference between the dates by using Julian Dates and by using substring functionality. But, getting the person age, it s completely depending upon your project requirement. Share your requirement, if you want some thoughts.
NageshSunkoji

If you know anything SHARE it.............
If you Don't know anything LEARN it...............
boppanakrishna
Participant
Posts: 106
Joined: Thu Jul 27, 2006 10:05 pm
Location: Mumbai

Re: Age of a person

Post by boppanakrishna »

Nageshsunkoji wrote:
ajith wrote:
boppanakrishna wrote:hi all,
how to calculate the "Age of a person" or "difference b/w dates" using the datastage functions

ThanksinAdvance
Boppana Krishna
Difference between dates can be found by converting the dates to Julianday and finding out the difference between them. But then finding out the age in years,months etc, will depend upon your business rules.
Thats true. We can acheive the difference between the dates by using Julian Dates and by using substring functionality. But, getting the person age, it s completely depending upon your project requirement. Share your requirement, if you want some thoughts.

yeah thanks for ur reply.. i want do develop the logic for the business logic" If incoming date is older than 5 years then reject"

My Approach--> first i have converted the incoming date into julian day and then i have done the difference between the julian days of incoming and the current Date..and then i have applied the function "DateFromJulianDay" but it showing the out out as "******"

can you suggest some thing ...when i have done the difference between the dates i goyt the julian day as 2994, then i have applied the DateFromJulianDay then i got the above output...
ajith
Participant
Posts: 86
Joined: Thu Nov 10, 2005 11:10 pm

Re: Age of a person

Post by ajith »

boppanakrishna wrote:

yeah thanks for ur reply.. i want do develop the logic for the business logic" If incoming date is older than 5 years then reject"

My Approach--> first i have converted the incoming date into julian day and then i have done the difference between the julian days of incoming and the current Date..and then i have applied the function "DateFromJulianDay" but it showing the out out as "******"

can you suggest some thing ...when i have done the difference between the dates i goyt the julian day as 2994, then i have applied the DateFromJulianDay then i got the above output...

Hey after finding the difference compare it with 5 years worth days
that would do.


Get year, month and day from incoming date , concatenate year+5,Month and day convert it back to date, if that is less than current date, it is older than 5 years.

If Dt is the incoming date

Code: Select all

 Stringtodate(YearFromDate(Dt)+5:MonthFromDate(Dt):MonthDayFromDate(Dt),'YYYYMMDD')

will give you the date after 5 years of incoming date. now you just have to compare it with current date, for that you can use DaysSinceFromDate function on this.

I think that would do
gbusson
Participant
Posts: 98
Joined: Fri Oct 07, 2005 2:50 am
Location: France
Contact:

Post by gbusson »

there is a bug with DaysSinceFromDate...

if the source date is not "constant" ("2000-01-01") but a date from the source flow of the transformer, performance is very poor!
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Age
Use a stage variable svCurrentDate initialized to current_date().
Use DaysSinceFromDate() to get age in years. Divide by 365.249 to get age in years, then apply the floor() function to get age in completed years.

Date Difference
Use subtraction of Julian dates, as posted earlier.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
boppanakrishna
Participant
Posts: 106
Joined: Thu Jul 27, 2006 10:05 pm
Location: Mumbai

Post by boppanakrishna »

ray.wurlod wrote:Age
Use a stage variable svCurrentDate initialized to current_date().
Use DaysSinceFromDate() to get age in years. Divide by 365.249 to get age in years, then apply the floor() function to g ...
hi ray,
Thanks for your reply ,i have tried with 365 before ..but what is the reason for ".249"i.e from (365.249)

Thanksalot
Boppana
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Leap years. 99 of them every 400 years.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply