Sukanya Moorthy
Sukanya Moorthy

Reputation: 109

Oracle TO_CHAR (timestamp) and timestamp differ in minutes and seconds

SELECT
TO_CHAR((current_timestamp), 'YYYY-MM-DD HH:MM:SS AM')  AS curr_time, current_timestamp, dbtimezone
FROM dual;

The result is:

curr_time  2014-05-22 12:05:23 PM
current_timestamp 22-MAY-14 12.39.23.447181000 PM ASIA/CALCUTTA
dbtimezone +00:00

why do curr_time and current_timestamp differ by minutes?

Upvotes: 2

Views: 22983

Answers (1)

Raphaël Althaus
Raphaël Althaus

Reputation: 60493

because MM are month, not minutes... (and 05 is... may)

You have to use MI

Change your format to

'YYYY-MM-DD HH:MI:SS AM'

Upvotes: 8

Related Questions