java date

i am getting date string from the gui. i have a query like:

if argument is after and date is 04/05/2006 what it is returning is like all the data after this specified date
 but actually it should return data when > = (date+1)

i dont want any data for 04/05/2006 since my argument is after..

i m stuck with all date arithmetics.

please help/
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Set the Calendar a day forward

cal.add(Calendar.DATE, 1);

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mayank SAssociate Director - Product EngineeringCommented:
>> but actually it should return data when > = (date+1)

Then you need to define the upper limit of the query (I assume its a DB query). It should have less than whatever is the date till which you want to see results.
Once you've followed what i suggested, if you're querying a db

java.sql.Date lower = new java.sql.Date(cal.getTimeInMillis());
java.sql.Date upper = new java.sql.Date(System.getTimeMillis()); // (IOW - now)

preparedStatement.setDate(i, lower);
preparedStatement.setDate(j, upper);
Fundamentals of JavaScript

Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.

gdv82Author Commented:

hi thx for the comments but what actually i m doing is like i m generating sqlquery based of the input using java beans. my gui and java code is separate.

             query.append(dateString + " to_date('" + date + "', 'mm/dd/yyyy') ");

here date is a string
if date is "05/04/2006" and argument is after then

i need data where date >= "05/05/2006"

You don't need to call to_date (see the code i posted)

use sql 'between' in your query
Mayank SAssociate Director - Product EngineeringCommented:
Post your entire code for query-building.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.