Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get Datetime to display in military time in oracle?

Tags:

sql

oracle

I am running some queries to track down a problem with our backup logs and would like to display datetime fields in 24-hour military time. Is there a simple way to do this? I've tried googling and could find nothing.

like image 529
George Mauer Avatar asked Sep 19 '08 15:09

George Mauer


People also ask

How do I display a date in YYYY-MM-DD format in Oracle?

You can use TO_CHAR in a query to display a DATE in any particular format, but, as you said, that makes the column a string, not a DATE. Usually, that doesn't matter. ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD';SELECT hiredate, ...

What is the date time format in Oracle?

The date format along with timestamp components : YYYY-MM-DD hh:mm:ss. YYYY-MM-DDThh:mm:ss. YYYY-MM-DD hh:mm:ss.

How do I add AM or PM in Oracle?

We are using sysdate to fetch date and time from the system also time format is set to 12 hours. SELECT TO_CHAR(sysdate, 'DD-MM-YYYY HH:MI:SS AM') As "Date format AM/PM" FROM dual; Output: In the below output, Date, time, and AM/PM format is displayed using to_char format in the oracle database.

Does Oracle have a time datatype?

Oracle Database has five date-time data types: TIMESTAMP. TIMESTAMP WITH TIME ZONE. TIMESTAMP WITH LOCAL TIME ZONE.


1 Answers

select to_char(sysdate,'DD/MM/YYYY HH24:MI:SS') from dual;

Give the time in 24 hour format.

More options are described here.

like image 105
Joe Skora Avatar answered Sep 26 '22 14:09

Joe Skora