The moose likes JDBC and the fly likes Resultset based on current Date and Time Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "Resultset based on current Date and Time" Watch "Resultset based on current Date and Time" New topic
Author

Resultset based on current Date and Time

SP Nam
Ranch Hand

Joined: Oct 15, 2003
Posts: 41
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

Joined: Jan 10, 2002
Posts: 56233
    
  13

Moved to the JDBC forum as this is more about the query than about the JSP.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 26218
    
  66

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


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
SP Nam
Ranch Hand

Joined: Oct 15, 2003
Posts: 41
I want to get products produced for current day, it will be on database server.

SP Nam
Sabarish Sasidharan
Ranch Hand

Joined: Aug 29, 2002
Posts: 73


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 ]

Sab<br /> <br />Perfection does not come from belief or faith. Talk does not count for anything. Parrots can do that. Perfection comes through selfless work.<br />Swami Vivekananda
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Resultset based on current Date and Time
 
Similar Threads
java.sql.Timestamp to Oracle date
Oracle date-time fields
Peculiar Problem while parsing xml file
Trying to see if incoming date parameter has a time attached or not (wwithout using midnight)
SQLException Cursor Closed