posted 13 years ago

Hi All,

The clarification i need is not JSP Related. But i never able to find the Forum for my clarification.

Problems:

i need to enter some vaues for Years like this 1.2 or 1(1.2 years or 1 year)

in my JSP, then i need to convert that date into no of days, i am doing that by multiplying 1.2 or 1*365 days, and after that i am using oracle function round to trim decimal values and based on no of days i am performing a search in oracle, to find some results.

but multiplying with 365 days, is not the correct way, because all years are not 365 days, so can anybody give me some knowledge, how to convert it into correct no of days to the year value i am passing.

please reply me , i am in very critical stage.

Regards,

Biswa Ranjan Mishra

The clarification i need is not JSP Related. But i never able to find the Forum for my clarification.

Problems:

i need to enter some vaues for Years like this 1.2 or 1(1.2 years or 1 year)

in my JSP, then i need to convert that date into no of days, i am doing that by multiplying 1.2 or 1*365 days, and after that i am using oracle function round to trim decimal values and based on no of days i am performing a search in oracle, to find some results.

but multiplying with 365 days, is not the correct way, because all years are not 365 days, so can anybody give me some knowledge, how to convert it into correct no of days to the year value i am passing.

please reply me , i am in very critical stage.

Regards,

Biswa Ranjan Mishra

Biswa Ranjan Mishra

brmishra mishra

Greenhorn

Posts: 6

brmishra mishra

Greenhorn

Posts: 6

posted 13 years ago

I'm not sure that 1.2 years is precise enough to even worry about leap years. With one decimal place you're only going to get a date within about 3.6525 days. Call the range 4 and your precision plus or minus 2. A day off for leap year is within tolerance.

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi

posted 13 years ago

I think you are assuming that the number has only two significant digits. Maybe the original poster means 1.20000 which would probably be precise enough for the leap day to make a difference. In which case, I agree with Steve's comments above. you should forget about Java and computers. Try and figure out how you would do this by hand. If someone told you that the world ends 1.2500 years from today, how would you figure out how many days that is if you want to account for any possible leap years? What if it is 2.333 years from today? What about 5.0000 years? Using different examples like this should help you to see how to develop an algorithm to do accomplish your task.

Regards,

Layne

Originally posted by Stan James:

I'm not sure that 1.2 years is precise enough to even worry about leap years. With one decimal place you're only going to get a date within about 3.6525 days. Call the range 4 and your precision plus or minus 2. A day off for leap year is within tolerance.

I think you are assuming that the number has only two significant digits. Maybe the original poster means 1.20000 which would probably be precise enough for the leap day to make a difference. In which case, I agree with Steve's comments above. you should forget about Java and computers. Try and figure out how you would do this by hand. If someone told you that the world ends 1.2500 years from today, how would you figure out how many days that is if you want to account for any possible leap years? What if it is 2.333 years from today? What about 5.0000 years? Using different examples like this should help you to see how to develop an algorithm to do accomplish your task.

Regards,

Layne