File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Help with select statements Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Help with select statements" Watch "Help with select statements" New topic
Author

Help with select statements

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
I need a select st that retrieves the current qtr date of employment using db2 date functions. result must be

7/7/2004
8/8/2004
9/9/2004
9/23/2004


Date of employment
1/1/2004
1/18/2004
3/5/2004
4/6/2004
6/2/2004
7/7/2004
8/8/2004
9/9/2004
9/23/2004
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30356
    
150

Shan,
I think this would be easier to do without using any special date functions in db2.

Your query could be something like:
select employment_date from table where employment_date > ? and employment_date < ?

You can easily figure out the start and end dates in java (Calendar class.) It's platform independent and might also perform faster (being a simpler query.)


[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
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
how do I find out given today's date which quarter it belongs to?

Like 9/24/04 belongs to qtr july-aug-sep)
David Ulicny
Ranch Hand

Joined: Aug 04, 2004
Posts: 724
use QUARTER function, it returns the quarter which the date belongs to.


SCJP<br />SCWCD <br />ICSD(286)<br />MCP 70-216
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
example please? Is this a java function?
[ September 24, 2004: Message edited by: shan javan ]
David Ulicny
Ranch Hand

Joined: Aug 04, 2004
Posts: 724
it is SQL function
1. select quarter(your_date_column) from your_table
2. select * from your_table where quarter(your_date_column) = 1

it returns 1-4
[ September 24, 2004: Message edited by: David Ulicny ]
 
 
subject: Help with select statements