cancel
Showing results for 
Search instead for 
Did you mean: 

Minus age from current date

Former Member
0 Kudos

Hi experts,

I have an Age field coming from sender system.

I need to minus the age from current date and provide the output in form of date towards the target system.

PLS help me out..

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

The requirement was changed

Former Member
0 Kudos

Hi

have a look at these

(How do I calculate the difference between two dates?)

http://joda-time.sourceforge.net/faq.html

Calculating the Difference Between Two Datetime Stamps

http://www.xmission.com/~goodhill/dates/deltaDates.html

Get difference in days

http://javaalmanac.com/egs/java.util/CompDates.html

Thanks

Gaurav

Former Member
0 Kudos

Whenever you say Age,it will be in reference to some date(normally its current date).

The age which you are getting will also be in reference to some date.just get the date(and if not current date) subtract it from current date and get the result.

Thanx

Aamir

Former Member
0 Kudos

Actaully the requirement is age data is coming from sender side out of which i need to minus this age from the current system date and the resultant date value is to be transformed to target system..

Former Member
0 Kudos

Hi

Then its better you create UDF. Bring both the dates and calculate age on basis of that.

Thanks

Gaurav

Former Member
0 Kudos

If i say i m 26 years old,that means i m 26 years old today(current date).if i say i was 25 years old.i need to specify when i was 25 years old(past date).It doesn't make sense that i say i was 25 years old but don't tell when i was 25 years old.

Age is always in reference to some specific date,you need to ask the sender system to tell you age is against which date and then use the UDF to subtract the past date from current date

Former Member
0 Kudos

Aamir,

The point is i am getting value in form of age....say 2yrs

i need to minus 2 years from current date, so that i will get the value in form of date (i.e ddmmyy format).

Former Member
0 Kudos

Gaurav i want the UDF code...

Former Member
0 Kudos

>>The point is i am getting value in form of age....say 2yrs

This is not age,its a duration:)

Anyway,for your case,take the yyyy part of the date field and just subtract 2 from it.

The currentDate standard function will give the current date,change the format to yyyyMMdd(default is yyyy/MM/dd),then use substring function to take the first 4 digits and then subtract 2 from it.

Thanx

Aamir

Former Member
0 Kudos

If this is the case then from current date sustring the year and then minus the age coming from source and then concatnate this result with dodays date & month.