• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

comparison of dates  RSS feed

 
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,
How to compare two dates in servlets iam using access as database.
vin
 
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved from Servlets to Java In General (Intermediate)
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do you want to compare the dates? Do you want to check if one is befor the other in time, if they are equal or what?
 
vin Hari
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,
Thank you for reply ,i want to compare dates means date in a database to current date.
i have written a query like this,
select * from tablename where date<=?
means date till today but this is comparing only days not month and year
please tell me how to do.
vin
 
Java Cowboy
Posts: 16084
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, you have written a query, now what does the rest of your code look like?

What is type the of the column "date" in the table "tablename" in the database?
Are you using a PreparedStatement in your Java code?
If so, then how are you setting the parameter value?
 
Ranch Hand
Posts: 884
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by vin pll:
Hello all,
Thank you for reply ,i want to compare dates means date in a database to current date.
i have written a query like this,
select * from tablename where date<=?
means date till today but this is comparing only days not month and year
please tell me how to do.
vin



I think this pretty much depends on the database you're using. The SQL for Oracle, MySQL and MSSQL varies and they may have their own optimized queries.
 
vin Hari
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,
Here iam taking the current date from the textfield and iam writing this in servlet like
req.getParameter(date1);//here date1 is the current date of the text box
it should compare with the database which is having all the dates of pending fees ok then this should compare all the fields of date but here it is comparing only day please modify this

select * from tablename where date<=?//date is a database field name
st.setString(1,date1);
iam using preparestatement only .
 
What could go wrong in a swell place like "The Evil Eye"? Or with this tiny ad?
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!