Created
May 5, 2011 07:18
-
-
Save shadda/956662 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create or replace function to_char2(v_timestamp interval, v_format varchar) returns text as $$ | |
declare | |
tmp_date varchar; | |
begin | |
select to_char(v_timestamp, v_format) into tmp_date; | |
if found then | |
select | |
cast(cast(extract(epoch from v_timestamp) / 3600 as int) as varchar) || | |
substring(tmp_date from 3) into tmp_date; | |
return tmp_date; | |
end if; | |
return NULL; | |
end; | |
$$ language plpgsql; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment