Func Toconvert Date Time

  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Func Toconvert Date Time as PDF for free.

More details

  • Words: 164
  • Pages: 2
create or replace function func_toconvert_date_time (v_date date,type varchar2) return date is -/*---------------------------------------------------------------------------------------------------------*/ --/*--created by : ashish murali -------------------------------------------------------------------*/ --/*--datelastmodified : 05-mar-2008 ---------------------------------------------------------------------*/ --/*--purpose : to change the timestamp into date and time part separately accordin the request -*/ --/* time will be in 01-jan-1900 hh24:mi:ss and date in dd-mon-yyyy 00:00:00 format --*/ --/*--version : 1.0 -----------------------------------------------------------------------------*/ --/*--sample : select func_toconvert_date_time(sysdate,'date') from dual; ----------------------*/ -/*---------------------------------------------------------------------------------------------------------*/ v_output date; --/*-to display the output v_error exception; --/*-handling exception begin -/*---------------------------------------------------------------------------------------------------------*/ --/*----------if the type requested is "date" then output will be date part of the timestamp data ------------*/ --/*----------time part default as 00:00:00 ------------------------------------------------------------------*/ -/*---------------------------------------------------------------------------------------------------------*/ if (type='date') then v_output := to_date(to_char(v_date,'dd-mon-yyyy')) ; return v_output; -/*---------------------------------------------------------------------------------------------------------*/ --/*----------if the type requested is "time" then output will be time part of the timestamp data -----------*/ --/*----------date default as "01-jan-1900"

------------------------------------------------------------------*/ -/*---------------------------------------------------------------------------------------------------------*/ elsif (type = 'time') then v_output := to_date('01-jan-1900 '|| to_char(v_date,'hh24:mi:ss')) ; return v_output; else raise v_error; end if; exception when v_error then raise_application_error(-20001,'please change your type - '||sqlcode||' -error'||sqlerrm); end; /

Related Documents

Func Toconvert Date Time
November 2019 20
Func
June 2020 10
Date Time Function
October 2019 12
Date And Time Solution
October 2019 10
Date
June 2020 29