laxmanperamalla
laxmanperamalla

Reputation: 551

How to save date into 24 hours format in oracle

I am new to Oracle, and I need to save date and time in an Oracle database.

I am using time stamp as datatype for row. But now my problem is it saves date and time in 12 hours format like this 17/11/2011 10:10:10 PM.

But I need it in 24 hours format like 17/11/2011 22:10:10. I didn't understand the results that Google search result provided. Can any one please help me by posting some code.

Upvotes: 5

Views: 38272

Answers (2)

Justin Cave
Justin Cave

Reputation: 231661

Oracle always stores timestamps (and dates) in a packed binary format that is not human readable. Formatting is done only when a timestamp (or a date) is converted to a string.

You can control the formatting of your output by coding an explicit to_char. For example

SELECT to_char( your_timestamp_column, 'DD/MM/YYYY HH24:MI:SS' ) 
  FROM your_table

Upvotes: 15

Martijn
Martijn

Reputation: 1620

Oracle stores timestamps in an internal format (with a default representation).

You can customize this representation on output like with the to_char() function.

For input (into the database) you can use to_date().

Upvotes: 6

Related Questions