简体   繁体   中英

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.

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

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() .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM