Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Resultset based on current Date and Time

 
SP Nam
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I want to show Date and one field value from database in a drop down. I am using jstl for this in my jsp page.
My query is like this:

select product_name from Product where production_timestamp > to_date('2005-10-25 00:00:00','yyyy-MM-dd hh24:mi:ss') and production_timestamp < to_date('2005-10-25 23:59:59','yyyy-MM-dd hh24:mi:ss')

I have to show the products produced for a particular day.

The query has to pick a current time stamp dynamically when I execute the jsp page.

Any suggestions.

SP Nam
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65335
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved to the JDBC forum as this is more about the query than about the JSP.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which timestamp are you trying to get?

1) the production_timestamp - add it to the query
2) the current time on the database server - add it to the query
3) the current time in the application - just use Java
 
SP Nam
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to get products produced for current day, it will be on database server.

SP Nam
 
Sabarish Sasidharan
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


current date returns current date in DB2. Not sure about other RDBMS, but they should have something similar. If you use Prepared statements, then use



and in the place of ? substitute -> new java.util.Date().
[ October 26, 2005: Message edited by: Sabarish Sasidharan ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic