Using oracle date format |Using the DATE Format Mask in pl/sql

0 Flares Twitter 0 Facebook 0 Google+ 0 LinkedIn 0 Buffer 0 Email -- Filament.io 0 Flares ×

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

Technorati Tags:
, , , ,

0 Flares Twitter 0 Facebook 0 Google+ 0 LinkedIn 0 Buffer 0 Email -- Filament.io 0 Flares ×

2 thoughts on “Using oracle date format |Using the DATE Format Mask in pl/sql

  1. Pingback: Oracle to_char() function and usage | SQL and PLSQL

Leave a Reply

Your email address will not be published. Required fields are marked *

Paged comment generated by AJAX Comment Page