Page 1 of 1

Age of a person

Posted: Wed Nov 29, 2006 1:42 am
by boppanakrishna
hi all,
how to calculate the "Age of a person" or "difference b/w dates" using the datastage functions

ThanksinAdvance
Boppana Krishna

Re: Age of a person

Posted: Wed Nov 29, 2006 1:53 am
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.

Age Of a Person

Posted: Wed Nov 29, 2006 2:51 am
by suresh.narasimha
Hi,

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

Regards,
Suresh N

Posted: Wed Nov 29, 2006 3:21 am
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!]

Re: Age of a person

Posted: Wed Nov 29, 2006 5:16 am
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.

Re: Age of a person

Posted: Wed Nov 29, 2006 7:40 am
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...

Re: Age of a person

Posted: Wed Nov 29, 2006 9:51 am
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

Posted: Wed Nov 29, 2006 10:33 am
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!

Posted: Wed Nov 29, 2006 2:21 pm
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.

Posted: Wed Nov 29, 2006 11:00 pm
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

Posted: Wed Nov 29, 2006 11:10 pm
by ray.wurlod
Leap years. 99 of them every 400 years.