# 2 cases not passing in module 3

any hints I am so stuck now??

i had the same issue and it was bcz the way we are calculating the differnce btwn dates (im sure u are just doing years but there is more)think urself what if it is just for 6 months or a week …
resolve it and mark it as solution if that helps u

hint : use this formula
((1 + Absolute Rate of Return) ^ (365/number of days)) – 1

You have to modify the logic you have wrote
You can get the hint what you have to modify by just looking at the name of the tests you are failing

yes i am doing endDate.getYear() - trade.getPurchaseDate().getYear(), is it wrong?

will ur code work for the dates like 2/4/1998 to 10/10/1998 …and give me the rate ?

yes, it is working 365/no of days for less than a year case.

Make sure you write 365.0 not 365
This matters a lot for accuracy

i was typecasting as double, wont it cover for 365.0

It will cover but I prefer 365.0😅

okay i will try, can you think of some other case that might fail.?

You can try .
You will get it whether build passes or not.
There should be a element of suprise

i hope so…

lol try ur code and make sure u just dont include years…and how will ur code react for 1 year and 6 months…will it just calulate dates or only years …think and check urself

@vaibhav98
let me clarify myself,
i am finding out difference of years if the result is greater than 0 then the given forumla
otherwise 365/no of days between two dates.
if enddate is not given or <startdate i am taking latest date.
is there anything i am leaving?

@yakshit
no bro, failed for same testcases

thats what i was doing…ur code will fail if the start date and end date has difference of 1 year and 6 months …bcz it will only return no of years but u left 6 months …what about them…

ohh, i got it now, shit i can’t believe i did this mistake,
so i guess i should apply 365/days for every case right?

Now you got it I guess

haha who knows ,if i keep drooping hints…that will break rules

did that work …?and u can use calculator and do some calculations to reach to a conclusion and close the thread if the issue is resolved