This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes JDBC and the fly likes To get  the date one week from current date Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "To get  the date one week from current date" Watch "To get  the date one week from current date" New topic
Author

To get the date one week from current date

pavani potnuru
Greenhorn

Joined: Nov 04, 2007
Posts: 11
Hi,
I need the get the currentdate+1 week . So that I can compare with another date which i get from database. Help me out in this. I have Oracle 9i. I need a query compatible to this version.
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3666
    
    2

You could do this easily in Java using the Calendar class. Does it need to be part of the query? Any Oracle solution you come up with is going to be pretty non-portable.
[ January 16, 2008: Message edited by: Scott Selikoff ]

My Blog: Down Home Country Coding with Scott Selikoff
Paul Campbell
Ranch Hand

Joined: Oct 06, 2007
Posts: 338
Originally posted by Scott Selikoff:
You could do this easily in Java using the Calendar class. Does it need to be part of the query? Any Oracle solution you come up with is going to be pretty non-portable.

[ January 16, 2008: Message edited by: Scott Selikoff ]


It's also pretty easy in almost any DBMS... there are differences... but they are all similar.

DB2

select current date + 7 day

Oracle

select sysdate + 7

mysql

SELECT CURDATE() + interval 7 day

or

SELECT DATEADD(currdate()interval 7 day)
[ January 16, 2008: Message edited by: Paul Campbell ]
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: To get the date one week from current date
 
Similar Threads
week days
Get WeekStart Date & End date by Week Number in java
Java calender get weeks in month, start date and enddate
how to find monday in a selected date
How to get weeks for a particular year with Calendar object