A date format can be used with to_date and to_char functions.There are number of different formats that can be used to convert dates in different ways.
This is useful while displaying date and converting string value of date to DATE data type object.
See the below example for Date format usage.
-- Created on 11/19/2008 by Globinch PLSQLTIPS declare -- Local variables here test_Date DATE; begin -- Initialize the date test_Date := to_date('12/12/2008','DD/MM/YYYY'); --To display day and all other details dbms_output.put_line('The date :' || to_char(test_Date,'Dy DD-MM-YYYY HH24:MI:SS')); --To display month in text dbms_output.put_line('The date :' || to_char(test_Date,'Dy DD-MON-YYYY HH24:MI:SS')); --To display 12HR format and milliseconds dbms_output.put_line('The date :' || to_char(sysdate,'YYYY/MM/DD HH12:MI:SS:ssss')); --To display AM/PM format dbms_output.put_line('The date :' || to_char(sysdate,'YYYY/MM/DD HH12:MI:SS:ssss AM ')); end; / The date :Fri 12-12-2008 00:00:00 The date :Fri 12-DEC-2008 00:00:00 The date :2008/11/19 03:29:15:151
Read
- Oracle comparing dates : dates, oracle, date comparison in oracle pl/sql
- ORA-01882: TIMEZONE REGION NOT FOUND |Oracle Error
- PL/SQL EXTRACT function for oracle datetime
- ALTER TABLE to ADD PRIMARY KEY in Oracle| Oracle ALTER TABLE
- oracle date difference | date difference in sql an…
- DATE Data type in Oracle|Oracle Dates and Times|Dates in Oracle
- Formatting date in SQL (Oracle) -Simple date forma…
- Database Schema | Oracle Schema Objects | What is database schema?
- Autonomous Transactions in PL/SQL
- SQL – Transaction Statements -Transaction Manageme…
- Savepoints In SQL Transactions. – SAVEPOINT
- Oracle Tablespace, and Datafiles – Introduction
- Formatting date in SQL (Oracle) -Simple date forma…
- FINDING database objects, finding valid and INVALI…
Technorati Tags:
oracle date format, date format, sql date, to_date, to_char
Pingback: Oracle to_char() function and usage | SQL and PLSQL
Thanks!