• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Resultset based on current Date and Time

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moved to the JDBC forum as this is more about the query than about the JSP.
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to get products produced for current day, it will be on database server.

SP Nam
 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic