Oracle - Extract Characters from String, Extract Date from Timestamp

Extract Characters from a string in Oracle using Regular Expression
function f_extract_string(in_position in number, iv_string in varchar2) return varchar2 is    
lv_retun_value varchar2(50);
begin             
        SELECT REGEXP_SUBSTR(iv_string,'[^,]+', 1,in_position)
        into lv_retun_value
        FROM DUAL;        
        
        return lv_retun_value;        
end f_extract_string;
Extract Date from Timestamp
function f_timestamp_to_date(iv_timestamp in varchar2) return date is    
  ldte_date date;
begin    

  select to_date(trunc(to_timestamp(iv_timestamp)))
  into ldte_date
  from dual;
  
  return ldte_date;          
end f_timestamp_to_date;
Comments are closed