• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

JDBC - Oracle newbie question

 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jamie,
Thank you very much for your help.
-Anoop
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic