Skip to Main Content
  • Questions
  • select time portion of date datatype.

Breadcrumb

Question and Answer

Chris Saxon

Thanks for the question, Nanditha.

Asked: April 04, 2007 - 4:07 pm UTC

Last updated: April 05, 2007 - 3:56 pm UTC

Version: 10.1.0

Viewed 10K+ times! This question is

You Asked

Tom,

Thank you for your time in advance.

I have a cust_trxn table that contains column trxn_dte_time which is of datatype date. I have a requirement to select the number of transactions that occur between 3.30 PM and 5.30 PM.

In the process of coming up with the time portion of the column I have tried:

SQL> select to_date(trxn_dte_time,'hh:mi:ss') from cl_cust_trxn
2 where cust_trxn_seq=24587811;
select to_date(trxn_dte_time,'hh:mi:ss') from cl_cust_trxn
*
ERROR at line 1:
ORA-01858: a non-numeric character was found where a numeric was expected

How do we select only the time portion of a date datatype.

Appreciate your help.





and Tom said...

select to_char(trxn_dte_time, 'hh24:mi:ss')
  from t
 where to_char(trxn_dte_time,'hh24mi' ) between '1530' and '1730';
   and .....

Rating

  (3 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Excellent

A reader, April 06, 2007 - 4:51 pm UTC

Very Usefull query , specially If I want to see the transaction in the database just for a particuar duration

Thank You

Nanditha Mamidi, April 09, 2007 - 9:20 am UTC

Thank you TOM.
That was right on time and most helpful as usual.

A reader, August 19, 2019 - 10:04 pm UTC