Create a function to convert string type variable to date type variable : Table of Type « PL SQL « Oracle PL / SQL

Home
Oracle PL / SQL
1.Aggregate Functions
2.Analytical Functions
3.Char Functions
4.Constraints
5.Conversion Functions
6.Cursor
7.Data Type
8.Date Timezone
9.Hierarchical Query
10.Index
11.Insert Delete Update
12.Large Objects
13.Numeric Math Functions
14.Object Oriented Database
15.PL SQL
16.Regular Expressions
17.Report Column Page
18.Result Set
19.Select Query
20.Sequence
21.SQL Plus
22.Stored Procedure Function
23.Subquery
24.System Packages
25.System Tables Views
26.Table
27.Table Joins
28.Trigger
29.User Previliege
30.View
31.XML
Oracle PL / SQL » PL SQL » Table of Type 
Create a function to convert string type variable to date type variable
    
SQL>
SQL> create or replace
  2  function my_to_datep_string in varchar2 return date
  3  as
  4      type fmtArray is table of varchar2(25);
  5
  6      l_fmts  fmtArray := fmtArray'dd-mon-yyyy', 'dd-month-yyyy',
  7                                    'dd/mm/yyyy',
  8                                    'dd/mm/yyyy hh24:mi:ss' );
  9      l_return date;
 10  begin
 11      for i in .. l_fmts.count
 12      loop
 13          begin
 14              l_return := to_datep_string, l_fmts(i) );
 15          exception
 16              when others then null;
 17          end;
 18          EXIT when l_return is not null;
 19      end loop;
 20
 21      if l_return is null )
 22      then
 23          l_return :=
 24             new_timeto_date('01011970','ddmmyyyy') 1/24/60/60 *
 25                       p_string, 'GMT', 'EST' );
 26      end if;
 27
 28      return l_return;
 29  end;
 30  /

Function created.

SQL>
SQL> select my_to_date('12-02-2008') from dual;
MY_TO_DATE('12-02-20
--------------------
12-FEB-2008 00:00:00

row selected.

SQL>
SQL> --

   
    
    
  
Related examples in the same category
1.Fetch a bulk into a table structure
2.Define a nested table type for each column
3.Extend once, outside the loop for better performance
4.A package to manage a list of employees
5.Fill table of custom type and use it in for loop to insert
6.Table of custome type indexed by BINARY_INTEGER
7.Reference type attribute through index
8.Use for loop to fill a table collection
9.Select bulk collect into
10.Use for loop to insert value to table collection and then use table collection in another insert statement
11.The EXISTS Table Attribute
12.FIRST & LAST Table Attributes
13.NEXT & PRIOR Table Attributes
14.Uses the COUNT method to display the number of rows contained in a table collection
15.How to do a bulk collect into a nested table.
16.How to do a bulk collect into an associative array
17.Table collection indexed by column type
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.