This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JDBC - Oracle newbie question

 
Nair Anoop
Ranch Hand
Posts: 68
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am using JDBC to interact with an Oracle DB. I have fields of DateTime type in the DB. I need to write a few queries which require the hour or a particular month for a given date.
I know that MySQL has specific functions such as MONTH(Date) which gives the month from a quey and can be used directly in a sql statement.
Could some of you guys who have used Oracle tell me the corresponding functions in Oracle.
eg. I need a list of the number of customers who came in each hour. I have a DateTime field in the DB. Any help with this query ?
Thanks in advance,
Anoop
 
Jamie Robertson
Ranch Hand
Posts: 1879
MySQL Database Suse
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
for the hour:
select to_char(date_column_name, 'HH12') from table where...
**note: 'HH12' = 1-12 or use 'HH24' = 0-24 hours

for the month:
select to_char(date_column_name, 'MM') from table where...
**note: 'MM'=two digit value or 'MONTH' = name of month padded with blanks to length of nine characters or 'MON' = 3 letter abbreviation of month.

Jamie
[This message has been edited by Jamie Robertson (edited November 30, 2001).]
 
Nair Anoop
Ranch Hand
Posts: 68
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jamie,
Thank you very much for your help.
-Anoop
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic