• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help with select statements

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 34850
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.)
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 724
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use QUARTER function, it returns the quarter which the date belongs to.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
example please? Is this a java function?
[ September 24, 2004: Message edited by: shan javan ]
 
David Ulicny
Ranch Hand
Posts: 724
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic