DAIRAV
DAIRAV

Reputation: 731

create oracle date with time stamp from HH24 string

I have hour in 'HH24' format. For example: '13:35' I need to convert this into today's date of '13:35' in the time stamp - "dd/mm/yyyy HH24:MI:SS".

To_timeStamp() method returning me the date with timestamp of starting of the month.

It is returning "01-Jul-2019 13:35:00", please help me to get today's date with the exact hour and minutes?

Upvotes: 0

Views: 163

Answers (1)

user330315
user330315

Reputation:

You need to concatenate the formatted date with your input and then convert that back to a timestamp:

select to_timestamp(to_char(sysdate, 'yyyy-mm-dd')||' 13:35', 'yyyy-mm-dd hh24:mi')
from dual;

If that time value is a column in your table, use that instead of the constant value:

select to_timestamp(to_char(sysdate, 'yyyy-mm-dd')||' '||the_time_column, 'yyyy-mm-dd hh24:mi')
from your_table;

Upvotes: 2

Related Questions